Solr query with dynamic field

时光毁灭记忆、已成空白 提交于 2019-12-11 07:27:36

问题


I have documents with the following link.* dynamic fields:

"docs": [{
    "id":"id1" 
    "link.1.text":"mytext"
    "link.1.nImg":1
    "link.2.text":"mytext"
    "link.2.nImg":2
}, {
    "id":"id2" 
    "link.1.text":"mytext"
    "link.1.nImg":1
    "link.2.text":"mytext"
    "link.2.nImg":1
}]

How can I get a query like : link.*.text:"mytext" or link.*.nImg:2 ?


回答1:


You couldn't do that in Solr.

Dynamic fields allow Solr to index fields that you did not explicitly define in your schema. This is useful if you discover you have forgotten to define one or more fields. Dynamic fields can make your application less brittle by providing some flexibility in the documents you can add to Solr.

In query you need to list exact name of a field name, so dynamic fields give you an index time flexibility

Some more info - https://cwiki.apache.org/confluence/display/solr/Dynamic+Fields



来源:https://stackoverflow.com/questions/28435695/solr-query-with-dynamic-field

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!