Search on the nth element in an array


(Dan Tuffery) #1

If I have an array in my index

{
"myArray":{
{
myValue:50
},
{
myValue:160
}
}
}

Is there a way to search on objects in the array by specifying the array
index value, in the example below I want to search on the first element in
the array

{
"query": {
"query_string":{"query":"myArray[0].myValue:50"}
}
}

The query above gives me a parse error.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.


(Lukáš Vlček) #2

If the position is important then I would recommend making an object field
from it. Thus it will be indexed and used for search in efficient way.

Regards,
Lukáš
Dne 18.10.2013 11:12 "dan" dan.tuffery@gmail.com napsal(a):

If I have an array in my index

{
"myArray":{
{
myValue:50
},
{
myValue:160
}
}
}

Is there a way to search on objects in the array by specifying the array
index value, in the example below I want to search on the first element in
the array

{
"query": {
"query_string":{"query":"myArray[0].myValue:50"}
}
}

The query above gives me a parse error.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #3