Searching on arrays of strings works, but on arrays of integers fails


(doug livesey) #1

Hi -- if I have this object indexed like so:
$ curl -XPUT "http://localhost:9200/items_test/items" '{ "id": 999,
"colours": [ "red", "blue" ], "colour_ids": [ 4, 9 ], "status": "forsale" }'

When I do a search on the "colours" array like this:
$ curl -XGET "http://localhost:9200/items_test/items/_search?pretty=true"
-d '{ "query": { "term": { "colours": "red" } } }'
It returns the object in the results as I would expect.

However, when I try to search on "colour_ids" like this:
$ curl -XGET "http://localhost:9200/items_test/items/_search?pretty=true"
-d '{ "query": { "term": { "colour_ids": 4 } } }'
It returns nothing.

Could someone advise me on how I can modify my second search so that it can
search for items dependent on the "colour_ids" array of integers?
Thankyou for any & all assistance,
Doug.


(doug livesey) #2

Okay, for now I'll just use strings for the ids (which does work), but
if anyone can suggest a better way, I'd be really grateful.
Thanks,
Doug.

On Oct 11, 10:54 pm, doug livesey biot...@gmail.com wrote:

Hi -- if I have this object indexed like so:
$ curl -XPUT "http://localhost:9200/items_test/items" '{ "id": 999,
"colours": [ "red", "blue" ], "colour_ids": [ 4, 9 ], "status": "forsale" }'

When I do a search on the "colours" array like this:
$ curl -XGET "http://localhost:9200/items_test/items/_search?pretty=true"
-d '{ "query": { "term": { "colours": "red" } } }'
It returns the object in the results as I would expect.

However, when I try to search on "colour_ids" like this:
$ curl -XGET "http://localhost:9200/items_test/items/_search?pretty=true"
-d '{ "query": { "term": { "colour_ids": 4 } } }'
It returns nothing.

Could someone advise me on how I can modify my second search so that it can
search for items dependent on the "colour_ids" array of integers?
Thankyou for any & all assistance,
Doug.


(doug livesey) #3

Huh.
It started working this morning.
Which is worrying, but I'll start a new thread for that particular worry.

On 12 October 2011 10:38, biot023 biot023@gmail.com wrote:

Okay, for now I'll just use strings for the ids (which does work), but
if anyone can suggest a better way, I'd be really grateful.
Thanks,
Doug.

On Oct 11, 10:54 pm, doug livesey biot...@gmail.com wrote:

Hi -- if I have this object indexed like so:
$ curl -XPUT "http://localhost:9200/items_test/items" '{ "id": 999,
"colours": [ "red", "blue" ], "colour_ids": [ 4, 9 ], "status": "forsale"
}'

When I do a search on the "colours" array like this:
$ curl -XGET "
http://localhost:9200/items_test/items/_search?pretty=true"
-d '{ "query": { "term": { "colours": "red" } } }'
It returns the object in the results as I would expect.

However, when I try to search on "colour_ids" like this:
$ curl -XGET "
http://localhost:9200/items_test/items/_search?pretty=true"
-d '{ "query": { "term": { "colour_ids": 4 } } }'
It returns nothing.

Could someone advise me on how I can modify my second search so that it
can
search for items dependent on the "colour_ids" array of integers?
Thankyou for any & all assistance,
Doug.


(Shay Banon) #4

If you can recreate when it did not work, it would be great.

On Wed, Oct 12, 2011 at 12:15 PM, doug livesey biot023@gmail.com wrote:

Huh.
It started working this morning.
Which is worrying, but I'll start a new thread for that particular worry.

On 12 October 2011 10:38, biot023 biot023@gmail.com wrote:

Okay, for now I'll just use strings for the ids (which does work), but
if anyone can suggest a better way, I'd be really grateful.
Thanks,
Doug.

On Oct 11, 10:54 pm, doug livesey biot...@gmail.com wrote:

Hi -- if I have this object indexed like so:
$ curl -XPUT "http://localhost:9200/items_test/items" '{ "id": 999,
"colours": [ "red", "blue" ], "colour_ids": [ 4, 9 ], "status":
"forsale" }'

When I do a search on the "colours" array like this:
$ curl -XGET "
http://localhost:9200/items_test/items/_search?pretty=true"
-d '{ "query": { "term": { "colours": "red" } } }'
It returns the object in the results as I would expect.

However, when I try to search on "colour_ids" like this:
$ curl -XGET "
http://localhost:9200/items_test/items/_search?pretty=true"
-d '{ "query": { "term": { "colour_ids": 4 } } }'
It returns nothing.

Could someone advise me on how I can modify my second search so that it
can
search for items dependent on the "colour_ids" array of integers?
Thankyou for any & all assistance,
Doug.


(doug livesey) #5

I haven't been able to yet, sorry -- I will try again, but I suspect that
this was just some weird, anomalous behaviour.

On 12 October 2011 22:16, Shay Banon kimchy@gmail.com wrote:

If you can recreate when it did not work, it would be great.

On Wed, Oct 12, 2011 at 12:15 PM, doug livesey biot023@gmail.com wrote:

Huh.
It started working this morning.
Which is worrying, but I'll start a new thread for that particular worry.

On 12 October 2011 10:38, biot023 biot023@gmail.com wrote:

Okay, for now I'll just use strings for the ids (which does work), but
if anyone can suggest a better way, I'd be really grateful.
Thanks,
Doug.

On Oct 11, 10:54 pm, doug livesey biot...@gmail.com wrote:

Hi -- if I have this object indexed like so:
$ curl -XPUT "http://localhost:9200/items_test/items" '{ "id": 999,
"colours": [ "red", "blue" ], "colour_ids": [ 4, 9 ], "status":
"forsale" }'

When I do a search on the "colours" array like this:
$ curl -XGET "
http://localhost:9200/items_test/items/_search?pretty=true"
-d '{ "query": { "term": { "colours": "red" } } }'
It returns the object in the results as I would expect.

However, when I try to search on "colour_ids" like this:
$ curl -XGET "
http://localhost:9200/items_test/items/_search?pretty=true"
-d '{ "query": { "term": { "colour_ids": 4 } } }'
It returns nothing.

Could someone advise me on how I can modify my second search so that it
can
search for items dependent on the "colour_ids" array of integers?
Thankyou for any & all assistance,
Doug.


(system) #6