Forums / Extensions / eZ Find / exact match from related objects

exact match from related objects

Author Message

roberto perata

Monday 20 June 2011 2:56:16 am

Hi,
I new to ezfind and I'm not able to get an exact match from a filter.
I have a class with an Objects Relates Attribute and I need to search all Articles matching the value on that attribute.

if for example I search "related" it also bring me "not_related".

My fetch is this:

fetch( ezfind, search, hash(
                                                 limit, 10,
                                                 subtree_array, array($canale_node_id),
                                                 ignore_visibility, false(),
                                                 filter, array('or',
                                                                 array('and', concat('ame_content/category:',$category_name),'published:[NOW-180DAY TO NOW]'),
                                                                 array('and', concat('ame_video/category:'  ,$category_name),'published:[NOW-180DAY TO NOW]')
                                                          ),
                                                 class_id, array( 'ame_video','ame_content'),
                                                 sort_by, hash(published, desc)))

 

where ame_content is the class identifier, category is the class attribute and the variable $category_name is the text i'm looking for.

Thanks if anyone could help.

Roberto

Ivo Lukac

Monday 20 June 2011 3:19:23 am

Hi,

Did you try to put $category_name in the quotes?

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

roberto perata

Monday 20 June 2011 3:24:41 am

"

Hi,

Did you try to put $category_name in the quotes?

"

Not in the fetch but in url:
http://localhost:8983/solr/select?q=attr_category_t:related&&fq=attr_category_t:"related"&fq=meta_path_si:69

Ivo Lukac

Monday 20 June 2011 3:49:36 am

When you filter some word, e.g. "foo bar", do you get all the results  or you get the result with category like "foo bar and beer"?

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

roberto perata

Monday 20 June 2011 3:55:19 am

Exactly, that's the problem.

If I filter "foo bar" i get also "fool" and "foo beer" etc

Ivo Lukac

Monday 20 June 2011 4:01:56 am

The problem is that ezfind uses "text" type for objectrelation attributes. The text type gets tokenized as any other free text field. To have an exact match you need to use "string" type which is basically used as one token. For that you have 2 options:

1. to set object relation attribute to use "string" via ezfind.ini

2. to create custom string based field in solr schema.xml adn use <copyfield> to populate it with content from original field(s)

The first option is easier, but second is better ;)

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

roberto perata

Monday 20 June 2011 4:58:18 am

Thanks for help me...do you mean someting like

<field name="attr_category_t" type="string" indexed="true" stored="true" multiValued="true"/>
in schema.xml ?

or in ezfind.ini
DatatypeMapFilter[ezstring]=simpletext

roberto perata

Monday 20 June 2011 5:01:12 am

we are using ezfind 2.1

Ivo Lukac

Monday 20 June 2011 5:10:25 am

"

Thanks for help me...do you mean someting like

<field name="attr_category_t" type="string" indexed="true" stored="true" multiValued="true"/>
in schema.xml ?

or in ezfind.ini
DatatypeMapFilter[ezstring]=simpletext

"

Yes, just to note that "attr_category_t" is probably a dynamic name already given by ezfind so you should name it e.g. "custom_category_s" or similar...

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

roberto perata

Monday 20 June 2011 5:16:29 am

attr_category_t is the name of the field I'm filtering as it results from http://localhost:8983/solr/select?q=*:*&start=&rows=50&&fq=subattr_category-ame_tag_t:"related"&fq=meta_path_si:69

Ivo Lukac

Monday 20 June 2011 5:30:33 am

"

attr_category_t is the name of the field I'm filtering as it results from http://localhost:8983/solr/select?q=*:*&start=&rows=50&&fq=subattr_category-ame_tag_t:"related"&fq=meta_path_si:69

"

Ok. My comment was aimed for the second solution, if you make an additional field...

But, anyway did you manage to solve the problem?

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

roberto perata

Monday 20 June 2011 5:42:03 am

Not yet, and the problem is also for a single word:

Search for "foo" get also "fool"

i've add  <field name="attr_category_t"         type="string" indexed="true" stored="true" multiValued="true"/> to field list of schema.xml

Ivo Lukac

Monday 20 June 2011 5:51:02 am

"

Not yet, and the problem is also for a single word:

Search for "foo" get also "fool"

"

That is weird... hm. Is that word ("fool") somehow concatenated or?

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

roberto perata

Monday 20 June 2011 5:54:26 am

Nope just a single word

roberto perata

Monday 20 June 2011 6:06:56 am

Yeahhh,
it works, I had to change an article to re-indexing

Thanks a lot

Ivo Lukac

Monday 20 June 2011 6:14:15 am

"

Yeahhh,
it works, I had to change an article to re-indexing

Thanks a lot

"

ROTFL 

Nice to hear :)

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

roberto perata

Monday 20 June 2011 8:35:33 am

Ooops one more question...

I'm albe to seach by url but I've to translate to ezfind fetch:
http://localhost:8983/solr/select?q=*:*&start=&rows=50&&fq=category_tag:"elated"

category_tag is the custom name of my fild.

So far I used filter based on <class_identifier>/<class_attribute>[/<sub_structure]:<value> but now it's related to my custom_attribute_declaration.

fetch( ezfind, search, hash(

limit, 6,
subtree_array, array($canale_node_id),
ignore_visibility, false(),
filter, array('or',
      array('and', concat('ame_content/category:"',$category_name,'"'),'published:[NOW-180DAY TO NOW]'),
       array('and', concat('ame_video/category:"'  ,$category_name,'"'),'published:[NOW-180DAY TO NOW]') 

                                        ),

 class_id, array( 'ame_video','ame_content'),
 sort_by, hash(published, desc)))

and now? how can I relate to new attribute? Do I have to switch to rawSolrRequest?

rawSolrRequest

                            

Ivo Lukac

Monday 20 June 2011 9:00:07 am

you can use the new attribute with 'attr_category_t' instead 'ame_content/category', you don't need to have 'or' either...

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

roberto perata

Monday 20 June 2011 11:40:45 pm

Well, thanks Ivo I solved my problem. I recap for those who could have the same question:

The problem was that the text coming from a related object was tokenizen. That's because the default settings was "text" datatype instead of "string".

I change schema.xml creating a new field call "foo" and copying into it the original field:

 <field name="foo" type="string" indexed="true" stored="true" multiValued="true" />

<copyField source="bar" dest="foo" />

then the fetch

......,
filter, concat('foo:', $text_to_search),
......

Thanks Ivo
Roberto

roberto perata

Thursday 23 June 2011 7:53:29 am

Ops it doesn't work...

it takes also results from other fields (attr_body_t).
Is there a way to restrict the results anly to my custom field, actually my fetch is:

etch( ezfind, search, hash(
                                                 subtree_array, array($canale_node_id),
                                                 ignore_visibility, false(),
                                                 filter,array(
                                                         concat($search_field,$category_name),
                                                         concat('-meta_id_si:',$actual_objectid)
                                                         ),
                                                 class_id, array( 'ame_video','ame_content'),
                                                 limit, 5,
                                                 sort_by, hash(published, desc)))

Thanks.

Roberto