[英]Unable to search attachment type field in an ElasticSearch indexed document
Search does not return any results although I do have a document that should match the query. 搜索没有返回任何结果,尽管我有一个应与查询匹配的文档。
I do have the ElasticSearch mapper-attachments plugin installed per https://github.com/elasticsearch/elasticsearch-mapper-attachments . 我确实每个https://github.com/elasticsearch/elasticsearch-mapper-attachments安装了ElasticSearch映射器附件插件。 I have also googled the topic as well as browsed similar questions in stack overflow, but have not found an answer.
我也用谷歌搜索了该主题,并在堆栈溢出中浏览了类似的问题,但没有找到答案。
Here's what I typed into a windows 7 command prompt: 这是我在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" : [ ]
}
}
Note that the base64 encoded value of "Hello" is "SGVsbG8=", which is the value I have inserted into the "my_attachment" field of the document. 请注意,“ Hello”的base64编码值是“ SGVsbG8 =“,这是我已插入文档的“ my_attachment”字段中的值。
I am assuming that the mapper-attachments plugin has been deployed correctly because I don't get an error executing the mapping command above. 我假设已正确部署了mapper-attachments插件,因为在执行上述映射命令时没有出现错误。
Any help would be greatly appreciated. 任何帮助将不胜感激。
What analyzer is running against the my_attachment
field? 哪个分析器针对
my_attachment
字段运行?
if it's the standard analyser (can't see any listed) then the Hello
in the text will be made lowercase in the index. 如果它是标准分析器(看不到任何列出的内容),则文本中的
Hello
将在索引中变为小写。
ie when doing a term search (which doesn't have an analyzer on it) - try searching for hello
例如,当进行术语搜索时(没有分析器)-尝试搜索“
hello
curl localhost:9200/tce/contact/_search?pretty -d'
{"query":
{"term":
{"my_attachment":"hello"
}}}'
you can also see which terms have been added to the index: 您还可以查看哪些术语已添加到索引中:
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.