Indexing a numeric range field


(Sander Toonen) #1

Hi!

I'm am looking for a way to index documents which contain numeric ranges.
E.g:

{

name: Document A
size: 100-200

}
{
name: Document B
size: 190-240
}
{
name: Document C
size: 230
}

I need to be able to query for a range so that all documents that have an
overlapping range will be returned:

195-220 should return A and B
230-235 should return B and C

I currently do not know of a way to index a range, only how to query for a
range.
Is anybody aware of a way to achieve this?

Thanks in advance!

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/1e3dda92-063b-4291-946c-45d1821ea511%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Andrew Cholakian-2) #2

You cannot index a range, but then you don't need to. You should look at
storing the range as two values, a range_floor, and a range_ceil. Then you
can use standard range filters in conjunction with a 'and' filter to find
what you're looking for. Be sure to read this blog post about caching
behavior and filters when used with ranges
(http://www.elasticsearch.org/blog/all-about-elasticsearch-filter-bitsets/).


Andrew Cholakian
Developer, Found Hosted Elasticsearch
www.found.no, @foundsays

On Thursday, December 12, 2013 4:34:23 AM UTC-8, Sander Toonen wrote:

Hi!

I'm am looking for a way to index documents which contain numeric
ranges. E.g:

{

name: Document A
size: 100-200

}
{
name: Document B
size: 190-240
}
{
name: Document C
size: 230
}

I need to be able to query for a range so that all documents that have an
overlapping range will be returned:

195-220 should return A and B
230-235 should return B and C

I currently do not know of a way to index a range, only how to query for a
range.
Is anybody aware of a way to achieve this?

Thanks in advance!

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/e397b833-68dd-444e-9b29-bc13ad92995a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #3