SPRING-DATA-SOLR: The first step. Reference code for Basic PO class and Schema.xml file: Https://github.com/spring-projects/spring-data-solr-examplesSolrpo class:
Package Com.md.product.po.so;import Com.wzy.pomelo.base.beans.po;import Org.apache.solr.client.solrj.beans.Field; Import Org.springframework.data.annotation.id;import org.springframework.data.solr.core.mapping.dynamic;/** * Class Description: SOLR Index PO class * * @author Fengyong * @version 1.0 * @since 1.0 * Created by Fengyong on 16/5/3 5:21. */public class Solrproductindex extends Po implements searchablesolrproductindexdefinition {/** * itemId * * @Id @Field (itemid_field_name) private String ITEMID; /** * Commodity Basic Properties Collection */@Dynamic @Field (filterqueryitemspecmap_field_name) Private map<string, List<strin G>> Filterqueryspuattrmap; /** * Commodity Basic Properties Collection */@Field (filterqueryitemspeclist_field_name) Private list<string> Filterqueryspuattrli Qty /** * Commodity Quality regulation attribute set * * Private map<string, string> Filterqueryitemspecmap; /** * Commodity Regulations attribute set * * Private list<string> filterqueryitemspeclist;}
Schema.xml file Definition:
<dynamicfield name= "filterqueryitem_*" type= "string" indexed= "true" multivalued= "true"/>
The resulting index might look like this:
Special Field Description:
The special field of this application is only a dynamic field filterqueryitem_*, which corresponds to the map collection in Java
Map<string, list<string>> Filterqueryspuattrmap;
filterqueryitem_*
A single dynamic field can produce a corresponding n solr normal field, and the name of each normal field is the key of the map collection in Java
Value in map is a list collection, which corresponds to the attribute multivalued in the Solr field, meaning a multivalued field
Solrpo and Schema.xml correspondence, understand the corresponding relationship of dynamic fields can be, other fields corresponding as long as the data type corresponds, you can match success, multivalued fields can be compared with string[] or list<string>.Incidentally, the fact that it was seen elsewhere and has been tested, the SOLR eight-hour time zone problem, the data in the SOLR management interface has a eight-hour time zone problem, but using SOLRJ or spring to find data is stored in the data, there is no time zone problem. So no special treatment is required.
SPRING-DATA-SOLR: The first step. Correspondence between the basic PO class and the Schema.xml file