Query based on array values

Hi,

Needed some help.
I need to query documents based on the inner values of an array.
{id:1 , version:[1],…}
{id:1 , version:[2],….}
{id:2 , version:[1,2],…}

I needed to do faceted search and also query based on version value.
Example if i query for version 1, i should get:
{id:1 , version:[1],…}
{id:2 , version:[1,2],…}

Example if i query for version 2, i should get:
{id:1 , version:[2],….}
{id:2 , version:[1,2],…}

please help,
Karan

You can just query on an array field as you would do for a normal field.
Take a look at the match query:
http://www.elasticsearch.org/guide/reference/query-dsl/match-query.html

Martijn

On 10 December 2012 13:52, karan jaskaran1981@gmail.com wrote:

Hi,

Needed some help.
I need to query documents based on the inner values of an array.
{id:1 , version:[1],…}
{id:1 , version:[2],….}
{id:2 , version:[1,2],…}

I needed to do faceted search and also query based on version value.
Example if i query for version 1, i should get:
{id:1 , version:[1],…}
{id:2 , version:[1,2],…}

Example if i query for version 2, i should get:
{id:1 , version:[2],….}
{id:2 , version:[1,2],…}

please help,
Karan

--
View this message in context: http://elasticsearch-users.115913.n3.nabble.com/Query-based-on-array-values-tp4026757.html
Sent from the ElasticSearch Users mailing list archive at Nabble.com.

--

--
Met vriendelijke groet,

Martijn van Groningen

--

Hi Martijn,

Thanks alot ...this worked for me.

Thanks,
Karan

On Tuesday, December 11, 2012 12:08:38 AM UTC+5:30, Martijn v Groningen
wrote:

You can just query on an array field as you would do for a normal field.
Take a look at the match query:
http://www.elasticsearch.org/guide/reference/query-dsl/match-query.html

Martijn

On 10 December 2012 13:52, karan <jaskar...@gmail.com <javascript:>>
wrote:

Hi,

Needed some help.
I need to query documents based on the inner values of an array.
{id:1 , version:[1],…}
{id:1 , version:[2],….}
{id:2 , version:[1,2],…}

I needed to do faceted search and also query based on version value.
Example if i query for version 1, i should get:
{id:1 , version:[1],…}
{id:2 , version:[1,2],…}

Example if i query for version 2, i should get:
{id:1 , version:[2],….}
{id:2 , version:[1,2],…}

please help,
Karan

--
View this message in context:
http://elasticsearch-users.115913.n3.nabble.com/Query-based-on-array-values-tp4026757.html
Sent from the ElasticSearch Users mailing list archive at Nabble.com.

--

--
Met vriendelijke groet,

Martijn van Groningen

--

Hi,
I have documents in a collection as per following structure.
Document 1 = { "A":[
{
"type": "1",
"method": "auto",
"value": "some data"
},
{
"type": "2",
"method": "auto",
"value": "some data"
},
{
"type": "3",
"method": "auto",
"value": "some data"
}],
...
...
}

Document 2 = { "A":[
{
"type": "1",
"method": "manual",
"value": "some data"
},
{
"type": "2",
"method": "auto",
"value": "some data"
},
{
"type": "3",
"method": "manual",
"value": "some data"
}],
...
...
}

Document 3 = { "A":[
{
"type": "1",
"method": "manual",
"value": "some data"
},
{
"type": "2",
"method": "manual",
"value": "some data"
},
{
"type": "3",
"method": "auto",
"value": "some data"
}],
...
...
}

On these documents, I want to query two fields in array A..
Example 1: if I query "A.type":"1" AND "A.method":"manual", I should get document 2 and document 3 in return.
Example 2: if I query "A.type":"2" AND "A.method":"auto", I should get document 1 and document 2 in return.
Example 3: if I query "A.type":"2" AND "A.method":"manual", I should get only document 3 in return.

Is there a way to achieve this in ElasticSearch?