简体   繁体   中英

Solr field alias for indexing and querying

I have a set of documents in a Solr index that have the fields, exact_title and alternative_title. I want to be able to search them by using the field title. So in other words the query title:Hello World should return documents that have an exact_title or an alternative_title "Hello World"

Is it possible to define as alias for a field during indexing time?

I solved defining copy fields in the schema.xml file.

Example:

<field name="title_txt" type="text_general" indexed="true" stored="false" multiValued="true"/>
<field name="exact_title_txt" type="text_general" indexed="true" stored="true" multiValued="false"/>
<field name="alternative_title_txt" type="text_general" indexed="true" stored="true" multiValued="false"/>
<copyField source="exact_title_txt" dest="title_txt"/>
<copyField source="alternative_title_txt" dest="title_txt"/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM