How do I use copyField (solr4) to create a field that's searchable across multiple fields?

StackOverflow https://stackoverflow.com/questions/15242431

  •  18-03-2022
  •  | 
  •  

Question

I'm trying to configure copyField, but the documentation is pretty light on syntax examples.

This is what I tried to do, but the "all" field has no documents after re-importing all my data:

   <field name="all" type="text_en_splitting" indexed="true" stored="false" multiValued="true" termVectors="true" version="1.5" />
   <copyField source="id" dest="all"/>
   <copyField source="item_name" dest="all"/>
   <copyField source="item_brand" dest="all"/>
   <copyField source="short_description" dest="all"/>
   <copyField source="long_description" dest="all"/>
   <copyField source="catalog_names" dest="all"/>
   <copyField source="categories" dest="all"/>
   <copyField source="keywords" dest="all"/>
   <copyField source="attributes" dest="all"/>

All I really need is this:

I have documents with all of these fields defined (id, item_name, short/long description, etc).

I want to search on most of the fields, but not store the values (I just return the document ID).

So:

  • Do I need to define a field for each of these attributes (item_name, short/long desc., etc.)?
  • Should I be copying them all into one field so I can search across all those fields? This is necessary right?
  • Is there a way that I should just import all of these fields into one solr field? How should my schema.xml look?

I don't have any searches that look at one particular fields at this time.

Was it helpful?

Solution

Do I need to define a field for each of these attributes
You need to define all the fields any way if you want to retrieve their values.

Should I be copying them all into one field so I can search across all those fields? This is necessary right? You would need to copy them to a single field and search over that field.

Is there a way that I should just import all of these fields into one solr field? How should my schema.xml look?
you can define dynamic fields and have a single copyfield to copy them to a single field

OTHER TIPS

It seems that my biggest problem in copyField was that I needed to drop and re-load the index to enable it. It was sufficient to add a doc that replaces an existing doc.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top