user6383418
user6383418

Reputation: 415

Kentico Custom Lucene Index with multiple facets that are similar - how to query?

I have created a custom index that stores multiple extra fields that I use to filter by. Say for example I am storing some facets to select Kite colors. Some kites have one color, others have multiple.

Kite A color: dark blue red orange deep red

Kite B color: blue

Where kite A colors are dark blue, red, orange, and deep red.

A query as such +color:blue would return both kite a and kite b, even though kite A color is deep blue but not blue. Only kite B should be returned.

My question is this - and its probably been hard for me to find and answer because I dont know the proper terminology, but how should I be storing the values in lucene so that I can separate the values (delimiter?). In addition, how do I phrase the query so that if I search for color:red it does not return rows that have the value color:"deep red"? And if I were to search for color:(deep red) it wont return rows that have "red" but not "deep red"

Upvotes: 0

Views: 241

Answers (2)

Rui
Rui

Reputation: 494

One suggestion here. Are you asking visitor to type in the color (I assume not), or you have a filter list that they can check to filter?

If its a filter list, then you may want to consider use "dark_blue" as the value and "dark blue" as the display. Both for content entry and filter. That way, the filter would be color:dark_blue.

Then your index for this can use "Start width" as the analyzer type, so when search "dark blue", it's looking at "dark_blue" as value, which "blue" will not return. Then, when search "blue", "dark_blue" will not show because it dosen't start with "blue..."

Upvotes: 0

Roman Hutnyk
Roman Hutnyk

Reputation: 1549

Take a look at search index analyzer types: search results depend on the analyzer type + search settings of the object (page type, custom table, etc.).

I think color field is marked tokenized in search settings, that's why it returns results that match individual tokens (subsets) of the field's value. If tokenized disabled, the search only returns items if the full value of the field exactly matches the search expression.

Upvotes: 1

Related Questions