As I stated above, the problem has been solved, but allow me to
explain in more detail how:
When I originally created the index, I used bare integers in
the json (not wrapped in quotes). For example,
$> curl -XPUT 'http://localhost:9200/myindex/mytype/33' -d '
{
"song_id": 1000987,
"band_id": 140534,
"song_title": "Aftermath",
"genre_id": 1396,
"genre_name": "Down Tempo",
"band_name": "Band X"
}'
With the index thus created the above queries where not working,
except for this one:
{"query":{"bool":{"must":
[
{"query_string" :
{ "query" :
"genre_id: or 1016 or 1034 or 1129" }
}
]
}},
"size": "100"
}
This query ignores the genre_id field specification and just
matches every field (not what I wanted, but since most of the
genre_ids where unique it 'kinda' worked, but occasionally
it did match other fields)
I fixed it by re-indexing, this time wrapping the bare integer
arguments in quotes, as follows:
curl -XPUT 'http://localhost:9200/myindex/mytype/33' -d '
{
"song_id": "1000987",
"band_id": "140534",
"song_title": "Aftermath",
"genre_id": "1396",
"genre_name": "Down Tempo",
"band_name": "Band X"
}'
Now all of the queries work as expected.
This seems to point to a discrepancy on how the parser/index
generator is handling bare integers vs. quoted ones.
On Dec 10, 7:00 pm, Shay Banon shay.ba...@elasticsearch.com wrote:
Those queries should work... . Can you gist a recreation of this (using curl)?
On Friday, December 10, 2010 at 10:40 PM, John Kirkley wrote:
I think I have solved this problem: I needed to add quotes around
numeric field arguments.
Elastic search will accept the bare integer fields and add them,
but then it does not handle searching them properly. Perhaps
this is a type issue?
On Dec 10, 1:07 pm, John Kirkley john.fredrick.kirk...@gmail.com
wrote:
Hi,
Thanks for the great search index API. Just having a difficulty
with a fairly straight forward boolean OR query.
I am trying to match a single field with my query, but I am
getting hits on other fields as well. I cannot figure out how to
limit the results to the single field.
Here is an example index entry:
{
"song_id": 3233490,
"band_id": 158406,
"song_title": "J. S. Bach: Siciliano from BWV 1031",
"genre_id": 1016,
"genre_name": "Baroque",
"band_name": "Virtually Baroque Players"
}
The following querys return 0 results:
{"query":
{"term" : { "genre_id": "1016" }}
}
{"query":{"bool":
{"must":[
{"query_string" : { "query" : "genre_id:1016" }}
]}
},
"size": "100"
}
I managed to get the following query to work,
{"query":{"bool":{"must":
[
{"query_string" :
{ "query" : "genre_id: or 1016" }
}
]
}},
"size": "100"
}
however, it is matching other fields as well.
This query does not return results either:
{"query":{"bool":{"must":
[
{"query_string" :
{ "query" : "genre_id:1016 or genre_id:1027" }
}
]
}},
"size": "100"
}