Query with multiple term constraints and facets


(butlermh) #1

Hi - is this a valid query?

When I run it, I get back results, but no facet results?

Is there another way of achieving the same result?

Thanks in advance!

{
"from": 0,
"size": 10,
"query": {
"term": {
"Genre": "x",
"Label": "y"
}
},
"facets": {
"Genre": {
"terms": {
"field": "Genre",
"size": 30
}
},
"Label": {
"terms": {
"field": "Label",
"size": 30
}
}
}
}

--
View this message in context: http://elasticsearch-users.115913.n3.nabble.com/Query-with-multiple-term-constraints-and-facets-tp2929050p2929050.html
Sent from the ElasticSearch Users mailing list archive at Nabble.com.


(Greg) #2

I'm new to elasticsearch, but as far as I can tell, you can only
specify one key-value pair per query term.

Give this is a go:

{
"from": 0,
"size": 10,
"query": {
"term": { "Genre": "x" },
"term": { "Label": "y" }
}
},
"facets": {
"Genre": {
"terms": {
"field": "Genre",
"size": 30
}
},
"Label": {
"terms": {
"field": "Label",
"size": 30
}
}
}
}

Hope that helps.

Greg

On May 11, 9:41 pm, butlermh markdigitalpeb...@gmail.com wrote:

Hi - is this a valid query?

When I run it, I get back results, but no facet results?

Is there another way of achieving the same result?

Thanks in advance!

{
"from": 0,
"size": 10,
"query": {
"term": {
"Genre": "x",
"Label": "y"
}
},
"facets": {
"Genre": {
"terms": {
"field": "Genre",
"size": 30
}
},
"Label": {
"terms": {
"field": "Label",
"size": 30
}
}
}

}

--
View this message in context:http://elasticsearch-users.115913.n3.nabble.com/Query-with-multiple-t...
Sent from the ElasticSearch Users mailing list archive at Nabble.com.


(Shay Banon) #3

This will still won't work, since you specify two elements within the "query". If you want to combine two queries, you need to combine them using hte bool query, for example in a should clause, holding both term queries.
On Saturday, May 14, 2011 at 1:23 AM, Greg wrote:

I'm new to elasticsearch, but as far as I can tell, you can only
specify one key-value pair per query term.

Give this is a go:

{
"from": 0,
"size": 10,
"query": {
"term": { "Genre": "x" },
"term": { "Label": "y" }
}
},
"facets": {
"Genre": {
"terms": {
"field": "Genre",
"size": 30
}
},
"Label": {
"terms": {
"field": "Label",
"size": 30
}
}
}
}

Hope that helps.

Greg

On May 11, 9:41 pm, butlermh markdigitalpeb...@gmail.com wrote:

Hi - is this a valid query?

When I run it, I get back results, but no facet results?

Is there another way of achieving the same result?

Thanks in advance!

{
"from": 0,
"size": 10,
"query": {
"term": {
"Genre": "x",
"Label": "y"
}
},
"facets": {
"Genre": {
"terms": {
"field": "Genre",
"size": 30
}
},
"Label": {
"terms": {
"field": "Label",
"size": 30
}
}
}

}

--
View this message in context:http://elasticsearch-users.115913.n3.nabble.com/Query-with-multiple-t...
Sent from the ElasticSearch Users mailing list archive at Nabble.com.


(Sumit Guptaa) #4

hi shay

if we want to facet for "x y" means to say "x y" treated as single term that what is the way to achieve this..

thanx in advance

Regards,
Sumit Gupta


(jagdeep) #5

You need to user keyword analyzer.

Regards
Jagdeep

On Tuesday, May 22, 2012 2:44:24 PM UTC+5:30, Sumit Gupta wrote:

hi shay

if we want to facet for "x y" means to say "x y" treated as single term
that
what is the way to achieve this..

thanx in advance

Regards,
Sumit Gupta

--
View this message in context:
http://elasticsearch-users.115913.n3.nabble.com/Query-with-multiple-term-constraints-and-facets-tp2939521p4006299.html
Sent from the ElasticSearch Users mailing list archive at Nabble.com.


(Sumit Guptaa) #6

hi jagdeep

keyword analyzer is working when we treated "x y" as the whole document and suppose we have document like "x y x y a b c" and when we want to apply facet query on "x y" it gives the result for whole document like "x y x y a b c":1

so please give me the way to achieve this..

thanx in advance

Regards
Sumit Gupta


(system) #7