2012-06-14 125 views
1

以下鏈接表示我們可以使用字段別名,例如id,price:crazy_price_field等。我嘗試使用它,但這不起作用。 http://wiki.apache.org/solr/CommonQueryParameters#Field_alias https://issues.apache.org/jira/browse/SOLR-1205Solr中的Solr字段別名搜索不起作用

我的查詢:

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 
      } 
     ] 
    } 
} 

回答

2

您指的是已添加到Solr 4.0版本的功能,尚未發佈。實際上,在該wiki頁面的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一起發佈。您可能需要查看Solr 4.0 roadmap以瞭解應該何時發佈它。

+0

感謝您的回答。 –