Solr search multiple categories and tags

I would like to use solr for the following scenario:

Each photo can have several sets. Each set will have 1 "category" and 1 "tag set":

eg. Photo A Set 1: “category” = solid (separate item); "tag set" = slim fit, vintage, red (multiple elements)

eg. Photo A Set 2: “category” = sandals (separate item); "tag set" = platform, red color (several elements)

We want to be able to search for Photos based on the above categories / tags: for example, “platform sandals”, “red one-piece”, etc.

Can someone tell us how we should create the necessary schema.xml file? (We do not need to show the faceted category in our case)

(solr version 1.4.1)

Thank you in advance

+4
source share
1 answer

You must add two fields to your schema. Both will be text fields. Your category is simple, but you will need to use a multi-valued field. See the following SO post - this is very important for what you do:

What is the use of the "multiValued" field type in Solr?

<field name="category" stored="true" indexed="true" type="text_general" /> <field name="tags" stored="true" indexed="true" type="text_general" multiValued="true"/> 

For your search, you can either add search handlers to view and enlarge certain fields, or copy both fields in the third field and search by the combined value in this third field. for instance

 <field name="text" stored="true" indexed="true" type="text_general" multiValued="true"/> <copyField dest="text" source="category"/> <copyField dest="text" source="tags"/> 
+2
source

All Articles