2

以下链接说我们可以使用字段别名,如 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,score给出正确的结果,字段名称为description_index_storescore

{
    "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,score的别名时,它不会返回该字段。

{
    "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
            }
        ]
    }
}
4

1 回答 1

3

您指的是已添加到 Solr 4.0 版本中但尚未发布的功能。事实上,在该wiki 页面的fl 部分中有一个感叹号,它告诉您以下内容(仍在 fl 部分中)仅适用于 Solr 4.0。

SOLR-1205 问题以及其他改进已在SOLR -2444 中得到解决:更新 fl 语法以支持:伪字段、AS、转换器和通配符,这将与 Solr 4.0 一起发布。您可能想查看Solr 4.0 路线图以了解何时发布它。

于 2012-06-14T11:52:42.080 回答