Querying a LONG field

Hi,

Using 0.16.2, I have a type that contains a field of type long, but I am
having difficulty writing a query against it. The field name is orgId, and
always contains an integer, the following queries produce no results:

{
"query": { "range": { "orgId": { "from": 123, "to": 123, "include_lower":
true, "include_upper": true }}}
}

{
"query": { "term": { "orgId": "123" }}
}

{
"query": { "term": { "orgId": 123 }}
}

{
"query": { "field": { "orgId": "123" }}
}

(and again without the quotes around 123).

I'm sure this is such an easy answer, but I can't quite figure it out. It
looks similar to this gist: https://gist.github.com/737631, but the
solutions there don't work. If it isn't a simple problem, I'll try to gist a
recreation tomorrow...

Thanks!

Adam

This should work, a recreation would be great.

On Wednesday, June 8, 2011 at 5:04 AM, Adam Creeger wrote:

Hi,

Using 0.16.2, I have a type that contains a field of type long, but I am having difficulty writing a query against it. The field name is orgId, and always contains an integer, the following queries produce no results:

{
"query": { "range": { "orgId": { "from": 123, "to": 123, "include_lower": true, "include_upper": true }}}
}

{
"query": { "term": { "orgId": "123" }}
}

{
"query": { "term": { "orgId": 123 }}
}

{
"query": { "field": { "orgId": "123" }}
}

(and again without the quotes around 123).

I'm sure this is such an easy answer, but I can't quite figure it out. It looks similar to this gist: gist:737631 · GitHub, but the solutions there don't work. If it isn't a simple problem, I'll try to gist a recreation tomorrow...

Thanks!

Adam

Hi Shay,

This was being caused by the orgId field being mapped in one type as a
string, and in another type (same index) as a long. Does that make sense?
Would it be possible to prevent/warn when you attempt to have 2 different
mappings for the same property in one index?

Thanks,

Adam

On 8 June 2011 02:12, Shay Banon shay.banon@elasticsearch.com wrote:

This should work, a recreation would be great.

On Wednesday, June 8, 2011 at 5:04 AM, Adam Creeger wrote:

Hi,

Using 0.16.2, I have a type that contains a field of type long, but I am
having difficulty writing a query against it. The field name is orgId, and
always contains an integer, the following queries produce no results:

{
"query": { "range": { "orgId": { "from": 123, "to": 123, "include_lower":
true, "include_upper": true }}}
}

{
"query": { "term": { "orgId": "123" }}
}

{
"query": { "term": { "orgId": 123 }}
}

{
"query": { "field": { "orgId": "123" }}
}

(and again without the quotes around 123).

I'm sure this is such an easy answer, but I can't quite figure it out. It
looks similar to this gist: https://gist.github.com/737631, but the
solutions there don't work. If it isn't a simple problem, I'll try to gist a
recreation tomorrow...

Thanks!

Adam

  • deleted -

Warning is a possible good idea. In general, you can work around it by explicitly saying which type field you want to search on (like type1.field1). Its similar to the problem mongodb has, where you can basically do whatever you want with types in documents, but you really don't want to mix it.

On Thursday, June 9, 2011 at 4:34 AM, Adam Creeger wrote:

Hi Shay,

This was being caused by the orgId field being mapped in one type as a string, and in another type (same index) as a long. Does that make sense? Would it be possible to prevent/warn when you attempt to have 2 different mappings for the same property in one index?

Thanks,

Adam

On 8 June 2011 02:12, Shay Banon <shay.banon@elasticsearch.com (mailto:shay.banon@elasticsearch.com)> wrote:

This should work, a recreation would be great.

On Wednesday, June 8, 2011 at 5:04 AM, Adam Creeger wrote:

Hi,

Using 0.16.2, I have a type that contains a field of type long, but I am having difficulty writing a query against it. The field name is orgId, and always contains an integer, the following queries produce no results:

{
"query": { "range": { "orgId": { "from": 123, "to": 123, "include_lower": true, "include_upper": true }}}
}

{
"query": { "term": { "orgId": "123" }}
}

{
"query": { "term": { "orgId": 123 }}
}

{
"query": { "field": { "orgId": "123" }}
}

(and again without the quotes around 123).

I'm sure this is such an easy answer, but I can't quite figure it out. It looks similar to this gist: gist:737631 · GitHub, but the solutions there don't work. If it isn't a simple problem, I'll try to gist a recreation tomorrow...

Thanks!

Adam