简体   繁体   中英

Solr : How to Index a field in document as json field?

I know we can index a document as json but I want to index a field inside my document as json.

eg

{
            id:"Person1",
            name:"bob",
            associatedCompanies:[
                                 {
                                     companyName:"apple",
                                     companyId:"c1"
                                 },
                                 {
                                     companyName:"google",
                                     companyId:"c2"
                                 }
                             ]
}

I can have associatedCompanies field as an array by declaring it as multiValued in schema. But how can I add company element as json?

I don't think the parent-child example applies here since in this use case, the json element which is nested is not exactly same as the document. I just want to add some json element in my document.

Does anyone have any idea how this can be indexed? And how to query with such index? Is it possible to do query like below..

id:person AND name:bob AND associatedCompanies:[{
                                     companyName:"apple",
                                     companyId:"c1"
                                 }]

or

id:person AND name:bob AND associatedCompanies:[{
                                         companyName:"apple"
                                     }]

In second query, will I get the response with the document having apple company?

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