以下链接说我们可以使用字段别名,如id,price:crazy_price_field等。我正在尝试使用它,但这不起作用。 http://wiki.apache.org/solr/CommonQueryParameters#Field_alias https://issues.apache.org/jira/browse/SOLR-1205
我的查询:
http://localhost:8080/solr/ee_core/select?indent=on&version=2.2&q=\*%3A\*&fq=%2BinstanceId_index_store%3A217&start=0&rows=10&fl=description_index_store%2Cscore&qt=&wt=json
fl = description_index_store,得分根据字段名称 description_index_store 和得分
提供正确的结果{
"responseHeader": {
"status": 0,"QTime": 1,
"params": {
"explainOther": "","fl": "description_index_store,score",
"indent": "on","start": "0","q": "*:*","hl.fl": "","qt": "",
"wt": "json","fq": "+instanceId_index_store:217","rows": "3",
"version": "2.2"
}
},
"response": {
"numFound": 128,"start": 0,"maxScore": 1,
"docs": [
{
"description_index_store": "Apple MacBook - Intel Core 2 Duo",
"score": 1
},
{
"description_index_store": "Apple MacBook - Intel Core 2 Duo",
"score": 1
},
{
"description_index_store": "HP Envy - 17.3\" - Intel Core i7",
"score": 1
}
]
}
}
但是当我尝试在同一个查询中使用别名,如 fl = description:description_index_store,得分时,它不会返回该字段。
{
"responseHeader": {
"status": 0,"QTime": 0,
"params": {
"explainOther": "","fl": "description:description_index_store,score",
"indent": "on","start": "0","q": "*:*","hl.fl": "","qt": "",
"wt": "json","fq": "+instanceId_index_store:217","rows": "3",
"version": "2.2"
}
},
"response": {
"numFound": 128,"start": 0,"maxScore": 1,
"docs": [
{
"score": 1
},
{
"score": 1
},
{
"score": 1
}
]
}
}
答案 0 :(得分:2)
您指的是已添加到Solr 4.0版本但尚未发布的功能。实际上,在该维基页面的fl section内有一个感叹号,它告诉您以下内容(仍在fl部分内)仅适用于Solr 4.0。
SOLR-1205 issue已在SOLR-2444: Update fl syntax to support: pseudo fields, AS, transformers, and wildcards内解决,Solr 4.0 roadmap已与Solr 4.0一起发布。您可能需要查看{{3}}以了解何时应该发布它。