簡體   English   中英

無法在ElasticSearch索引文檔中搜索附件類型字段

[英]Unable to search attachment type field in an ElasticSearch indexed document

搜索沒有返回任何結果,盡管我有一個應與查詢匹配的文檔。

我確實每個https://github.com/elasticsearch/elasticsearch-mapper-attachments安裝了ElasticSearch映射器附件插件。 我也用谷歌搜索了該主題,並在堆棧溢出中瀏覽了類似的問題,但沒有找到答案。

這是我在Windows 7命令提示符下鍵入的內容:

c:\Java\elasticsearch-1.3.4>curl -XDELETE localhost:9200/tce
{"acknowledged":true}

c:\Java\elasticsearch-1.3.4>curl -XPUT localhost:9200/tce
{"acknowledged":true}

c:\Java\elasticsearch-1.3.4>curl -XPUT localhost:9200/tce/contact/_mapping -d{\"
contact\":{\"properties\":{\"my_attachment\":{\"type\":\"attachment\"}}}}
{"acknowledged":true}

c:\Java\elasticsearch-1.3.4>curl -XPUT localhost:9200/tce/contact/1 -d{\"my_atta
chment\":\"SGVsbG8=\"}
{"_index":"tce","_type":"contact","_id":"1","_version":1,"created":true}

c:\Java\elasticsearch-1.3.4>curl localhost:9200/tce/contact/_search?pretty
{
  "took" : 2,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 1.0,
    "hits" : [ {
      "_index" : "tce",
      "_type" : "contact",
      "_id" : "1",
      "_score" : 1.0,
      "_source":{"my_attachment":"SGVsbG8="}
    } ]
  }
}

c:\Java\elasticsearch-1.3.4>curl localhost:9200/tce/contact/_search?pretty -d{\"
query\":{\"term\":{\"my_attachment\":\"Hello\"}}}
{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 0,
    "max_score" : null,
    "hits" : [ ]
  }
}

請注意,“ Hello”的base64編碼值是“ SGVsbG8 =“,這是我已插入文檔的“ my_attachment”字段中的值。

我假設已正確部署了mapper-attachments插件,因為在執行上述映射命令時沒有出現錯誤。

任何幫助將不勝感激。

哪個分析器針對my_attachment字段運行?

如果它是標准分析器(看不到任何列出的內容),則文本中的Hello將在索引中變為小寫。

例如,當進行術語搜索時(沒有分析器)-嘗試搜索“ hello

 curl localhost:9200/tce/contact/_search?pretty -d'
     {"query":
       {"term":
         {"my_attachment":"hello"
      }}}'

您還可以查看哪些術語已添加到索引中:

curl 'http://localhost:9200/tce/contact/_search?pretty=true' -d '{
   "query" : {
      "match_all" : { }
   },
   "script_fields": {
      "terms" : {
        "script": "doc[field].values",
        "params": {
            "field": "my_attachment"
         }
       }
    }
 }'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM