Hi,
I have the following (json) query i use:
{
"fields": ["ID","ID2"],
"query": {
"filtered": {
"query": {
"multi_match": {
"query": "",
"fields": ["FIELD1.not_analyzed","FIELD2.partial"]
}
},
"filter": {
"bool": {
"must": [
{ "term" : { "FIELD2": "No" } },
{ "term" : {"FIELD3": "Yes" } }
]
}
}
}
},
"sort": [
{
"SCORE": {
"order": "desc"
}
}
]
}
but my attempts a building the same query with the Java API hasn't been
fruitful.The goal is to search for a match based on a searchterm in several
fields and some fields are more important than others.
I know the basic setup:
.client
.prepareSearch()
.setSearchType(SearchType.QUERY_AND_FETCH)
.setQuery(QueryBuilders.multiMatchQuery(searchterm, "FIELD1.not_analyzed",
"FIELD2.partial"))
.addSort("SCORE", SortOrder.DESC)
.setSize(10)
.execute()
.actionGet();
but there are no results while the json query has a returnvalue. So 2
questions:
i could use some help formulating the right Java query
why is the json return stuff and the java query not?
Thanks,
Maarten
--
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/166a43b2-d92c-4307-abed-2ce95ae87fb2%40googlegroups.com .
For more options, visit https://groups.google.com/d/optout .
roger
(Roger)
December 1, 2014, 1:20pm
2
You can use the toString() method of the SearchRequestBuilder to see the
generated query. With your example it was:
{
"size" : 10,
"query" : {
"multi_match" : {
"query" : "searchterm",
"fields" : [ "FIELD1.not_analyzed", "FIELD2.partial" ]
}
},
"sort" : [ {
"SCORE" : {
"order" : "desc"
}
} ]
}
This query looks ok. Are you not receiving any results? Not even the
"total" value?
2014-11-28 16:11 GMT-02:00 Maarten Roosendaal mroosendaal14@gmail.com :
Hi,
I have the following (json) query i use:
{
"fields": ["ID","ID2"],
"query": {
"filtered": {
"query": {
"multi_match": {
"query": "",
"fields": ["FIELD1.not_analyzed","FIELD2.partial"]
}
},
"filter": {
"bool": {
"must": [
{ "term" : { "FIELD2": "No" } },
{ "term" : {"FIELD3": "Yes" } }
]
}
}
}
},
"sort": [
{
"SCORE": {
"order": "desc"
}
}
]
}
but my attempts a building the same query with the Java API hasn't been
fruitful.The goal is to search for a match based on a searchterm in several
fields and some fields are more important than others.
I know the basic setup:
.client
.prepareSearch()
.setSearchType(SearchType.QUERY_AND_FETCH)
.setQuery(QueryBuilders.multiMatchQuery(searchterm, "FIELD1.not_analyzed",
"FIELD2.partial"))
.addSort("SCORE", SortOrder.DESC)
.setSize(10)
.execute()
.actionGet();
but there are no results while the json query has a returnvalue. So 2
questions:
i could use some help formulating the right Java query
why is the json return stuff and the java query not?
Thanks,
Maarten
--
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/166a43b2-d92c-4307-abed-2ce95ae87fb2%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/166a43b2-d92c-4307-abed-2ce95ae87fb2%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/CAJp2532Z8bataicKD%2BrUECd4yoJkXZd47MMVssgoE%3DK8opXhCg%40mail.gmail.com .
For more options, visit https://groups.google.com/d/optout .