Ankita
Ankita

Reputation: 1456

Frequently Index SearchTerm to Solr

I am working on eCommerce web application which is developed using DOT NET MVC. I use Solr to index product details. So that I have mentioned Product related fields to my Solr Schema file.

Now I also want to index SearchTerm to Solr. For this how can I manage my Schema file to store/index searchterm as my Schema file is product specific?

Can anyone please suggest?

Upvotes: 0

Views: 27

Answers (1)

Abhijit Bashetti
Abhijit Bashetti

Reputation: 8658

You can have a separate core for this and define the new schema.xml for it or if you want to use the existing schema.xml then you can make use of the dynamic fields by which you need not have bother in future if any other field you need to add..

You can use Dynamic fields.

Dynamic fields allow Solr to index fields that you did not explicitly define in your schema.

This is useful if you discover you have forgotten to define one or more fields. Dynamic fields can make your application less brittle by providing some flexibility in the documents you can add to Solr.

A dynamic field is just like a regular field except it has a name with a wildcard in it. When you are indexing documents, a field that does not match any explicitly defined fields can be matched with a dynamic field.

For example, suppose your schema includes a dynamic field with a name of *_i.

If you attempt to index a document with a cost_i field, but no explicit cost_i field is defined in the schema, then the cost_i field will have the field type and analysis defined for *_i.

Like regular fields, dynamic fields have a name, a field type, and options.

<dynamicField name="*_i" type="int" indexed="true"  stored="true"/>

Upvotes: 1

Related Questions