Range query in percolate not working

I'm trying to use the Percolate features. It seems to work fine for text,
but when I try a range query with numeric values I get odd behavior. Every
document seems to have the same query and it shouldn't! Can anyone see
what I'm doing wrong?

//create index
$ curl -XPUT localhost:9200/jperctest3
{"ok":true,"acknowledged":true}

//insert a bunch of queries to the percolator
$ curl -XPOST 'http://localhost:9200/_percolator/jperctest3/' -d
'{"query":{"range":{"hits":{"from":50,"to":75,"include_lower":true,"include_upper":true}}}}'
{"ok":true,"_index":"_percolator","_type":"jperctest3","_id":"QMQ3mo_8RSWidcFOgbdxGg","_version":1}

$ curl -XPOST 'http://localhost:9200/_percolator/jperctest3/' -d
'{"query":{"range":{"hits":{"from":50,"to":60,"include_lower":true,"include_upper":true}}}}'
{"ok":true,"_index":"_percolator","_type":"jperctest3","_id":"omenhMF5QDaD6LGORa38wg","_version":1}

$ curl -XPOST 'http://localhost:9200/_percolator/jperctest3/' -d
'{"query":{"range":{"hits":{"from":5,"to":20,"include_lower":true,"include_upper":true}}}}'
{"ok":true,"_index":"_percolator","_type":"jperctest3","_id":"mhsSnSNgQR6fGysbCHNAkw","_version":1}

$ curl -XPOST 'http://localhost:9200/_percolator/jperctest3/' -d
'{"query":{"range":{"hits":{"from":1,"to":9,"include_lower":true,"include_upper":true}}}}'
{"ok":true,"_index":"_percolator","_type":"jperctest3","_id":"WopYvt70TqOkd-9CngZivQ","_version":1}

//now add documents
$ curl -XGET localhost:9200/jperctest3/site/_percolate -d
'{"doc":{"hits":30}}'
{"ok":true,"matches":["WopYvt70TqOkd-9CngZivQ"]}

$ curl -XGET localhost:9200/jperctest3/site/_percolate -d
'{"doc":{"hits":4}}'
{"ok":true,"matches":["WopYvt70TqOkd-9CngZivQ"]}

$ curl -XGET localhost:9200/jperctest3/site/_percolate -d
'{"doc":{"hits":0}}'
{"ok":true,"matches":["WopYvt70TqOkd-9CngZivQ"]}

$ curl -XGET localhost:9200/jperctest3/site/_percolate -d
'{"doc":{"hits":-1}}'
{"ok":true,"matches":["WopYvt70TqOkd-9CngZivQ"]}

$ curl -XGET localhost:9200/jperctest3/site/_percolate -d
'{"doc":{"hits":-10000000}}'
{"ok":true,"matches":["WopYvt70TqOkd-9CngZivQ"]}

Just to add: basically any value of "hits" that I percolate the return says
is matches the 1-9 range above.

On Thursday, April 26, 2012 10:19:44 AM UTC-4, jschelle wrote:

I'm trying to use the Percolate features. It seems to work fine for text,
but when I try a range query with numeric values I get odd behavior. Every
document seems to have the same query and it shouldn't! Can anyone see
what I'm doing wrong?

//create index
$ curl -XPUT localhost:9200/jperctest3
{"ok":true,"acknowledged":true}

//insert a bunch of queries to the percolator
$ curl -XPOST 'http://localhost:9200/_percolator/jperctest3/' -d
'{"query":{"range":{"hits":{"from":50,"to":75,"include_lower":true,"include_upper":true}}}}'

{"ok":true,"_index":"_percolator","_type":"jperctest3","_id":"QMQ3mo_8RSWidcFOgbdxGg","_version":1}

$ curl -XPOST 'http://localhost:9200/_percolator/jperctest3/' -d
'{"query":{"range":{"hits":{"from":50,"to":60,"include_lower":true,"include_upper":true}}}}'

{"ok":true,"_index":"_percolator","_type":"jperctest3","_id":"omenhMF5QDaD6LGORa38wg","_version":1}

$ curl -XPOST 'http://localhost:9200/_percolator/jperctest3/' -d
'{"query":{"range":{"hits":{"from":5,"to":20,"include_lower":true,"include_upper":true}}}}'

{"ok":true,"_index":"_percolator","_type":"jperctest3","_id":"mhsSnSNgQR6fGysbCHNAkw","_version":1}

$ curl -XPOST 'http://localhost:9200/_percolator/jperctest3/' -d
'{"query":{"range":{"hits":{"from":1,"to":9,"include_lower":true,"include_upper":true}}}}'

{"ok":true,"_index":"_percolator","_type":"jperctest3","_id":"WopYvt70TqOkd-9CngZivQ","_version":1}

//now add documents
$ curl -XGET localhost:9200/jperctest3/site/_percolate -d
'{"doc":{"hits":30}}'
{"ok":true,"matches":["WopYvt70TqOkd-9CngZivQ"]}

$ curl -XGET localhost:9200/jperctest3/site/_percolate -d
'{"doc":{"hits":4}}'
{"ok":true,"matches":["WopYvt70TqOkd-9CngZivQ"]}

$ curl -XGET localhost:9200/jperctest3/site/_percolate -d
'{"doc":{"hits":0}}'
{"ok":true,"matches":["WopYvt70TqOkd-9CngZivQ"]}

$ curl -XGET localhost:9200/jperctest3/site/_percolate -d
'{"doc":{"hits":-1}}'
{"ok":true,"matches":["WopYvt70TqOkd-9CngZivQ"]}

$ curl -XGET localhost:9200/jperctest3/site/_percolate -d
'{"doc":{"hits":-10000000}}'
{"ok":true,"matches":["WopYvt70TqOkd-9CngZivQ"]}

On Thursday, April 26, 2012 10:19:44 AM UTC-4, jschelle wrote:

I'm trying to use the Percolate features. It seems to work fine for text,
but when I try a range query with numeric values I get odd behavior. Every
document seems to have the same query and it shouldn't! Can anyone see
what I'm doing wrong?

//create index
$ curl -XPUT localhost:9200/jperctest3
{"ok":true,"acknowledged":true}

//insert a bunch of queries to the percolator
$ curl -XPOST 'http://localhost:9200/_percolator/jperctest3/' -d
'{"query":{"range":{"hits":{"from":50,"to":75,"include_lower":true,"include_upper":true}}}}'

{"ok":true,"_index":"_percolator","_type":"jperctest3","_id":"QMQ3mo_8RSWidcFOgbdxGg","_version":1}

$ curl -XPOST 'http://localhost:9200/_percolator/jperctest3/' -d
'{"query":{"range":{"hits":{"from":50,"to":60,"include_lower":true,"include_upper":true}}}}'

{"ok":true,"_index":"_percolator","_type":"jperctest3","_id":"omenhMF5QDaD6LGORa38wg","_version":1}

$ curl -XPOST 'http://localhost:9200/_percolator/jperctest3/' -d
'{"query":{"range":{"hits":{"from":5,"to":20,"include_lower":true,"include_upper":true}}}}'

{"ok":true,"_index":"_percolator","_type":"jperctest3","_id":"mhsSnSNgQR6fGysbCHNAkw","_version":1}

$ curl -XPOST 'http://localhost:9200/_percolator/jperctest3/' -d
'{"query":{"range":{"hits":{"from":1,"to":9,"include_lower":true,"include_upper":true}}}}'

{"ok":true,"_index":"_percolator","_type":"jperctest3","_id":"WopYvt70TqOkd-9CngZivQ","_version":1}

//now add documents
$ curl -XGET localhost:9200/jperctest3/site/_percolate -d
'{"doc":{"hits":30}}'
{"ok":true,"matches":["WopYvt70TqOkd-9CngZivQ"]}

$ curl -XGET localhost:9200/jperctest3/site/_percolate -d
'{"doc":{"hits":4}}'
{"ok":true,"matches":["WopYvt70TqOkd-9CngZivQ"]}

$ curl -XGET localhost:9200/jperctest3/site/_percolate -d
'{"doc":{"hits":0}}'
{"ok":true,"matches":["WopYvt70TqOkd-9CngZivQ"]}

$ curl -XGET localhost:9200/jperctest3/site/_percolate -d
'{"doc":{"hits":-1}}'
{"ok":true,"matches":["WopYvt70TqOkd-9CngZivQ"]}

$ curl -XGET localhost:9200/jperctest3/site/_percolate -d
'{"doc":{"hits":-10000000}}'
{"ok":true,"matches":["WopYvt70TqOkd-9CngZivQ"]}

I figured this out, but thought I'd post it so someone else can find it
later. Basically I was relying on the automapper (not explicitly defining
the fields in my index). Apparently that doesn't always work. I added the
line below right after I create the index and now it works perfectly.

curl -XPUT 'http://localhost:9200/jperctest5/site/_mapping' -d
'{"site":{"properties":{"hits":{"type":"integer"},"content":{"type":"string"},"site":{"type":"string"}
}}}'

On Thursday, April 26, 2012 10:19:44 AM UTC-4, jschelle wrote:

I'm trying to use the Percolate features. It seems to work fine for text,
but when I try a range query with numeric values I get odd behavior. Every
document seems to have the same query and it shouldn't! Can anyone see
what I'm doing wrong?

//create index
$ curl -XPUT localhost:9200/jperctest3
{"ok":true,"acknowledged":true}

//insert a bunch of queries to the percolator
$ curl -XPOST 'http://localhost:9200/_percolator/jperctest3/' -d
'{"query":{"range":{"hits":{"from":50,"to":75,"include_lower":true,"include_upper":true}}}}'

{"ok":true,"_index":"_percolator","_type":"jperctest3","_id":"QMQ3mo_8RSWidcFOgbdxGg","_version":1}

$ curl -XPOST 'http://localhost:9200/_percolator/jperctest3/' -d
'{"query":{"range":{"hits":{"from":50,"to":60,"include_lower":true,"include_upper":true}}}}'

{"ok":true,"_index":"_percolator","_type":"jperctest3","_id":"omenhMF5QDaD6LGORa38wg","_version":1}

$ curl -XPOST 'http://localhost:9200/_percolator/jperctest3/' -d
'{"query":{"range":{"hits":{"from":5,"to":20,"include_lower":true,"include_upper":true}}}}'

{"ok":true,"_index":"_percolator","_type":"jperctest3","_id":"mhsSnSNgQR6fGysbCHNAkw","_version":1}

$ curl -XPOST 'http://localhost:9200/_percolator/jperctest3/' -d
'{"query":{"range":{"hits":{"from":1,"to":9,"include_lower":true,"include_upper":true}}}}'

{"ok":true,"_index":"_percolator","_type":"jperctest3","_id":"WopYvt70TqOkd-9CngZivQ","_version":1}

//now add documents
$ curl -XGET localhost:9200/jperctest3/site/_percolate -d
'{"doc":{"hits":30}}'
{"ok":true,"matches":["WopYvt70TqOkd-9CngZivQ"]}

$ curl -XGET localhost:9200/jperctest3/site/_percolate -d
'{"doc":{"hits":4}}'
{"ok":true,"matches":["WopYvt70TqOkd-9CngZivQ"]}

$ curl -XGET localhost:9200/jperctest3/site/_percolate -d
'{"doc":{"hits":0}}'
{"ok":true,"matches":["WopYvt70TqOkd-9CngZivQ"]}

$ curl -XGET localhost:9200/jperctest3/site/_percolate -d
'{"doc":{"hits":-1}}'
{"ok":true,"matches":["WopYvt70TqOkd-9CngZivQ"]}

$ curl -XGET localhost:9200/jperctest3/site/_percolate -d
'{"doc":{"hits":-10000000}}'
{"ok":true,"matches":["WopYvt70TqOkd-9CngZivQ"]}

Heya,

Yea, because the mapping is not there for the field when you register the
percolator query (and no document was indexed to derive the mapping for),
the queries were registered as simple "string" ranges. Thanks for following
this up with your solution.

-shay.banon

On Thu, Apr 26, 2012 at 7:00 PM, jschelle jason.scheller@gmail.com wrote:

I figured this out, but thought I'd post it so someone else can find it
later. Basically I was relying on the automapper (not explicitly defining
the fields in my index). Apparently that doesn't always work. I added the
line below right after I create the index and now it works perfectly.

curl -XPUT 'http://localhost:9200/jperctest5/site/_mapping' -d
'{"site":{"properties":{"hits":{"type":"integer"},"content":{"type":"string"},"site":{"type":"string"}
}}}'

On Thursday, April 26, 2012 10:19:44 AM UTC-4, jschelle wrote:

I'm trying to use the Percolate features. It seems to work fine for
text, but when I try a range query with numeric values I get odd behavior.
Every document seems to have the same query and it shouldn't! Can anyone
see what I'm doing wrong?

//create index
$ curl -XPUT localhost:9200/jperctest3
{"ok":true,"acknowledged":**true}

//insert a bunch of queries to the percolator
$ curl -XPOST 'http://localhost:9200/_**percolator/jperctest3/http://localhost:9200/_percolator/jperctest3/'
-d '{"query":{"range":{"hits":{"from":50,"to":75,"include_
lower":true,"include_upper":**true}}}}'
{"ok":true,"index":"**percolator","_type":"**jperctest3","id":"QMQ3mo
**8RSWidcFOgbdxGg","_version":1}

$ curl -XPOST 'http://localhost:9200/_**percolator/jperctest3/http://localhost:9200/_percolator/jperctest3/'
-d '{"query":{"range":{"hits":{"from":50,"to":60,"include_
lower":true,"include_upper":**true}}}}'
{"ok":true,"index":"**percolator","type":"jperctest3","_id":"
omenhMF5QDaD6LGORa38wg","
**version":1}

$ curl -XPOST 'http://localhost:9200/_**percolator/jperctest3/http://localhost:9200/_percolator/jperctest3/'
-d '{"query":{"range":{"hits":{"from":5,"to":20,"include_
lower":true,"include_upper":**true}}}}'
{"ok":true,"index":"**percolator","type":"jperctest3","_id":"
mhsSnSNgQR6fGysbCHNAkw","
**version":1}

$ curl -XPOST 'http://localhost:9200/_**percolator/jperctest3/http://localhost:9200/_percolator/jperctest3/'
-d '{"query":{"range":{"hits":{"from":1,"to":9,"include_lower"
:true,"include_upper":true}}}}**'
{"ok":true,"index":"**percolator","type":"jperctest3","_id":"
WopYvt70TqOkd-9CngZivQ","
**version":1}

//now add documents
$ curl -XGET localhost:9200/jperctest3/**site/_percolate -d
'{"doc":{"hits":30}}'
{"ok":true,"matches":["**WopYvt70TqOkd-9CngZivQ"]}

$ curl -XGET localhost:9200/jperctest3/**site/_percolate -d
'{"doc":{"hits":4}}'
{"ok":true,"matches":["**WopYvt70TqOkd-9CngZivQ"]}

$ curl -XGET localhost:9200/jperctest3/**site/_percolate -d
'{"doc":{"hits":0}}'
{"ok":true,"matches":["**WopYvt70TqOkd-9CngZivQ"]}

$ curl -XGET localhost:9200/jperctest3/**site/_percolate -d
'{"doc":{"hits":-1}}'
{"ok":true,"matches":["**WopYvt70TqOkd-9CngZivQ"]}

$ curl -XGET localhost:9200/jperctest3/**site/_percolate -d
'{"doc":{"hits":-10000000}}'
{"ok":true,"matches":["**WopYvt70TqOkd-9CngZivQ"]}