2016-05-01 122 views
0

我已經上傳和Solr中提取6.0.0的文件,我看到它使用了下面的查詢索引:Solr的搜索無法正常工作

http://localhost:8983/solr/techproducts/select?indent=on&q=id:doc1&wt=json

{ 
    "responseHeader":{ 
    "status":0, 
    "QTime":1, 
    "params":{ 
     "q":"id:doc1", 
     "indent":"on", 
     "wt":"json"}}, 
    "response":{"numFound":1,"start":0,"docs":[ 
     { 
     "links":["http://www.education.gov.yk.ca/"], 
     "id":"doc1", 
     "last_modified":"2008-06-04T22:47:36Z", 
     "title":[" PDF Test Page"], 
     "content_type":["application/pdf"], 
     "author":"Yukon Canada Yukon Department of Education", 
     "author_s":"Yukon Canada Yukon Department of Education", 
     "content":[" \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n PDF Test Page \n \n \n \n \nPDF Test File \n \nCongratulations, your computer is equipped with a PDF (Portable Document Format) \nreader! You should be able to view any of the PDF documents and forms available on \nour site. PDF forms are indicated by these icons: or . \n \nYukon Department of Education \nBox 2703 \nWhitehorse,Yukon \nCanada \nY1A 2C6 \n \nPlease visit our website at: http://www.education.gov.yk.ca/\n \n \n \n \n "], 
     "_version_":1533049305513852928}] 
    }} 

我請參閱該字段內容有多個出現字PDF

爲什麼我沒有得到的結果與下面的查詢,當有一個字段名稱content它包含PDF ?:

select?q=*:*&fq=content:PDF 

{ 
    "responseHeader":{ 
    "status":0, 
    "QTime":4, 
    "params":{ 
     "q":"*:*", 
     "indent":"on", 
     "fq":"content:PDF", 
     "rows":"50", 
     "wt":"json"}}, 
    "response":{"numFound":0,"start":0,"docs":[] 
    }} 

裏面當我查詢中使用不同的領域,例如title,那我也正確的結果:

select?q=*:*&fq=title:PDF 

{ 
    "responseHeader":{ 
    "status":0, 
    "QTime":3, 
    "params":{ 
     "q":"*:*", 
     "indent":"on", 
     "fq":"title:PDF", 
     "rows":"50", 
     "wt":"json"}}, 
    "response":{"numFound":1,"start":0,"docs":[ 
     { 
     "links":["http://www.education.gov.yk.ca/"], 
     "id":"doc1", 
     "last_modified":"2008-06-04T22:47:36Z", 
     "title":[" PDF Test Page"], 
     "content_type":["application/pdf"], 
     "author":"Yukon Canada Yukon Department of Education", 
     "author_s":"Yukon Canada Yukon Department of Education", 
     "content":[" \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n PDF Test Page \n \n \n \n \nPDF Test File \n \nCongratulations, your computer is equipped with a PDF (Portable Document Format) \nreader! You should be able to view any of the PDF documents and forms available on \nour site. PDF forms are indicated by these icons: or . \n \nYukon Department of Education \nBox 2703 \nWhitehorse,Yukon \nCanada \nY1A 2C6 \n \nPlease visit our website at: http://www.education.gov.yk.ca/\n \n \n \n \n "], 
     "_version_":1533049305513852928}] 
    }} 
+0

請你分享schema.xml中... –

回答

0

檢查schema.xml爲內容field定義的field type

比較內容和標題字段的字段類型。

可能是您沒有爲您的字段內容定義適當的字段類型。這些字段類型不會爲您的文本生成任何標記,或者必須將整個文本視爲一個整體。如果您在字段中使用keywordtokenizerstring字段類型,則會發生這種情況。

您可以勾選相同的檢查或分析Solr調試工具。

在這裏您可以檢查文本是如何編制索引以及如何搜索文本的。

如果您想在field上搜索,那麼您必須提及屬性indexed=true,並且您希望solr返回相同的值,然後您需要添加stored=true

這兩個attribute幫助您實現搜索和檢索字段的原始值

+0

我有以下的託管模式:<字段名=「內容「type =」text_general「indexed =」false「stored =」true「multiValued =」true「/> and 。那麼我應該將內容字段的索引屬性更改爲true並重新啓動sorl服務器? – user1563721

+0

我將其更改爲true並且沒有更改...我仍無法搜索「內容」字段。 – user1563721

+0

更改後..您需要重新啓動服務器並重新索引數據.. –

相關問題