SOLR federated multiple fields for retrieval (use of multivalued and Copyfield)

Source: Internet
Author: User
Tags solr

Not only does the search for individual fields in the index work in practice. A comprehensive query is required.
For example, the Book table has id,name (title), Price,summary (abstract), content (contents), we want to find a books, query the keyword "Ordinary World", need to be included in the title or summary or content of the keyword when it is found. This requires the use of Copyfield and multivalue tags.

In Schema.xml, you will need to retrieve the fields, use Copyfield to copy to a new SearchText field, and set the Multivalue property of this SearchText field to true.

    <fields> <field name= "id" type= "string" indexed= "true" stored= "true" required= "true"/> <field name= "name" type= "TEXTMAXWORD_CN" indexed= "true" stored= "true"/> <field name= "Price" type= "Long" indexed= "true" stored= "true"/> <field name= "Summary" type= "TEXTMAXWORD_CN" indexed= "true" stored= "True"/> <field name= "content" type= "TEXTMAXWORD_CN" indexed= "true" stored= "true"/> <f Ield name= "SearchText" type= "TEXTMAXWORD_CN" indexed= "true" stored= "false" multivalued= "true"/> <field na Me= "Createtime" type= "string" indexed= "true" stored= "false"/> </fields> <uniquekey>id</un iquekey> <defaultSearchField>searchText</defaultSearchField> <solrqueryparser Defaultopera Tor= "and"/> <copyfield source= "name" dest= "SearchText"/> <copyfield source= "Summary" dest= "se   Archtext "/>

And can set the retrieval time, which field occupies a little more weight.
The following can be set in Solrconfig.xml:

<requesthandler name= "Dismax" class= "SOLR. Searchhandler ">
    <lst name=" Defaults ">
        <str name=" Deftype ">edismax</str>
        <str Name= "Echoparams" >explicit</str>
        <float name= "Tie" >0.1</float>
        <!--
        <str Name= "BF" >scoreparser (type) </str>
        <str name= "BF" >sum (Recip (MS (now,last_modified), 3.16e-11,1,1), Div (1000,price)) ^100</str>
        <str name= "PF" >
            name^100 summary^50 content^20
        </str>
        <str name= "QF" >
            name^10 summary^ content^2
        </str>

</ Requesthandler>

The definitions of these two parameters are found on the Internet:

PF: Provides the ability to match multiple fields of a record
QF: Set a different boost weight score for each field in the query, and set the field to be the item configured in PF.

Case Explanation :

HTTP://LOCALHOST:8080/SOLR/SELECT?DEFTYPE=DISMAX&QF=NAME^10 Summary ^1 &q= Ordinary World &pf=name^50 summary ^1 &q.op=or&bf=sum (Recip (MS (Now,createtime), 3.16e-11,1,1), Div (1000,price)) ^100
The query means: Search for the keyword "mundane world" in name and summary, and the specific gravity of name and summary in the field query is 10, 1 (qf=qf=name^10 summary ^1), and the two fields phrase are divided into
PF=NAME^50 summary ^1, that is, the name accounted for the proportion of 50, and the proportion of summary accounted for the small point, and the query takes into account the price of books and book Shelf Time (Bf=sum (Recip (Now,last_createtime), 3.16e-11,1,1), Div (1000,price)) ^100)

The BF can implement its own definition.
For multi-field search, you can also look at the introduction of this article: http://adminjun.iteye.com/blog/2258480

CLOB types of fields may be stored in the actual project, which requires additional processing, please refer to the blog in detail : http://blog.csdn.net/u010248330/article/details/72957645

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.