SPRING-DATA-SOLR: The first step. Correspondence between the basic PO class and the Schema.xml file

Source: Internet
Author: User
Tags solr

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.