Reputation: 115
I have a tagging system and tags are like this:
italian kitchen
chinese kitchen
japanese kitchen
russian kitchen
vegeterian kitchen
When I query italian kitchen, I don't get the italian kitchen on top. I get russian and japanese all the time and other irrelevant results. In Solr schema, my tags field's type is string. I have no idea why this is happening. Can you share your ideas with me?
Upvotes: 1
Views: 842
Reputation: 2499
make sure you do:
q=your_field:"italian kitchen"
and not
q=your_field:italian kitchen
Upvotes: 0
Reputation: 65599
The field type of "string" means your fields aren't getting tokenized. So each field has a single token -- the entire string passed in. So unless there's an exact phrase query match on the entire field, no result will be more relevant than any other,
You probably want to use the type "text" in the default schema, this will break up the field into tokens. IE instead of "Italian kitchen" you'll have both "Italian" and "kitchen" terms indexed in the field.
Upvotes: 4
Reputation: 9789
You really want to read through the section on tokenizers, at least the first two sections. And then, if you are in Solr 4, go to Admin interface and try the Analysis screen under your core's section. That allows you to put your text in with your type (cat) and see what it actually breaks down to.
Now, it sounds to me like you want that "Italian Kitchen" to be a facet category as well as searchable. That's a double challenge because the facet values come from tokens produced, so you do want that as a string. In which case, my suggestion is to keep cat field as a string field and do copyField into cat_text which has a tokenized type (look in example's schema) and use eDismax to search across multiple fields including cat_text.
Upvotes: 1