Based on the previous gist ( https://gist.github.com/1075067 https://gist.github.com/1075067 ), I tried to search on file field (aka the attachment field).
I searched for :
curl "${host}/_search?pretty=true" -d '{
"fields" : ["file"],
"query" : {
"query_string" : {
"query" : "amplifier"
}
},
"highlight" : {
"fields" : {
"file" : {}
}
}
}'
And get the result.
{
"took" : 81,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 0.005872132,
"hits" : [ {
"_index" : "test",
"_type" : "attachment",
"_id" : "s_C9wgsCQRKteC4i_WbjjQ",
"_score" : 0.005872132,
"fields" : {
"file" : "[I REMOVED THE PDF CONTENT] "
},
"highlight" : {
"file" : [ "\nMono <em>Amplifier</em>\nThe ISL99201 is a fully integrate d high efficiency class-D \nmono <em>amplifier</em>. It is designed" ]
}
} ]
}
}
I really think that your mapping is incorrect. Don’t you see something strange in logs when you create your mapping ?
I already get the same issue but it was due to a wrong install of the attachment plugin.
HTH
David.
De : elasticsearch@googlegroups.com [mailto:elasticsearch@googlegroups.com] De la part de Alexandre Heimburger
Envoyé : mercredi 14 mars 2012 18:51
À : elasticsearch mailing list
Objet : Query string on an attachment field
Hi,
Is it possible to perform a query string on a specific attachment field :
{
"query_string" : {
"fields" : ["files", "content"],
"query" : "my text"
}
}
This query should search in the content AND the attachments.
But nothing is returned. If I keep the default field, it's ok.
Am I missing something in the mapping ("files":{"type":"attachment"}) ?
thx
--
cheers,
ahb