My application interface offers fields for filtering (and they are working
on elastic), but for power users there is always the free text query
option, my query in elastic is as follows:
"query" : {
"filtered" : {
"query" : {
"match" : {
"texto" : {
"query" : "computer",
"operator" : "and"
}
}
},
"filter" : {
"bool" : {
"must" : [
{
"range" : {
"datefield"
: {
"gte" : "some date here",
"lte" : "some date here"
}
}
},
{
"term" : {
"filter1" : 1 }
},
{
"term" : {
"filter2" : 1 }
},
{
"term" : {
"filter3" : [5] }
}
]
}
}
}
}
That is the structure that I use for every query, the filter values vary
upon the choices entered by the user, and the "query" itself gets its value
from a text entry field.
Up to this point everything works fine, but when I put "category:0003
computer" in the query field, it does not return results, although there
are results the comply...
On Tuesday, December 16, 2014 8:55:01 PM UTC-5, David Pilato wrote:
Actually, elasticsearch will search computer in _all field and as you said
0003 in category field.
You should may be disable _all field and use the copy_to feature instead
BTW.
If your interface has different inputs for text and category, then you
should probably better use the QueryDSL with for example a FilteredQuery,
with a matchQuery and a termFilter.
My 2 cents
David
Le 17 déc. 2014 à 02:27, Bruno Kamiche <bkam...@gmail.com <javascript:>>
a écrit :
I need to query elasticsearch and let the user specify on which other
fields to search for certain attributes...
I have a field named "texto" with the actual text on which queries are
done.
I have a field name "category" with values like "0001,0003" (meaning the
record is on categories 1 and 3), or "0001,0005,0007", etc...
If the user enters a search criteria like "computer" it will search on
field "texto" for the text computer, that works fine.
But I guess there is an option, in which you can specify things like
"category:0003 computer", this query would need to find records with the
text "computer" on the field "texto", and additionaly have the value "0003"
present on the field "category", is this possible?
Bruno
--
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 elasticsearc...@googlegroups.com <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/36882ade-d788-43b7-95fb-96f6d653f934%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/36882ade-d788-43b7-95fb-96f6d653f934%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.
--
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/de59e565-8b10-4cae-8fdb-17aa43591804%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.