I am trying to search for some keywords (eg java, hibernate, j2ee, jSP etc)
in two text fields [summary and description]. Since I need to get records
with any of the key words, I am using *BooleanQuery *
with should clause. And to search, I am using Multi-Match query. Below
is my query,
The query is working fine, but I want to get records with keyword java
first and then get records with other keywords. How can I achieve this?
I am trying to search for some keywords (eg java, hibernate, j2ee, jSP etc) in two text fields [summary and description]. Since I need to get records with any of the key words, I am using BooleanQuery
with should clause. And to search, I am using Multi-Match query. Below is my query,
The query is working fine, but I want to get records with keyword java first and then get records with other keywords. How can I achieve this?
Thanks for your reply. Java is not mandatory term. I want Elasticsearch to
return records having term Java first(if such records exists) followed by
records with other terms. Basically, I want to search for 2-3 keywords and
I should be able to sort results based on one of the search terms (java in
this case)
On Tuesday, April 7, 2015 at 12:17:01 PM UTC+5:30, David Pilato wrote:
You mean that Java is a mandatory term?
In that case use a must clause instead of should.
David
Le 7 avr. 2015 à 08:03, rav...@gmail.com <javascript:> a écrit :
Hello,
I am trying to search for some keywords (eg java, hibernate, j2ee, jSP
etc) in two text fields [summary and description]. Since I need to get
records with any of the key words, I am using *BooleanQuery *
with should clause. And to search, I am using Multi-Match query.
Below is my query,
The query is working fine, but I want to get records with keyword java
first and then get records with other keywords. How can I achieve this?
Thanks for your reply. Java is not mandatory term. I want Elasticsearch to return records having term Java first(if such records exists) followed by records with other terms. Basically, I want to search for 2-3 keywords and I should be able to sort results based on one of the search terms (java in this case)
On Tuesday, April 7, 2015 at 12:17:01 PM UTC+5:30, David Pilato wrote:
You mean that Java is a mandatory term?
In that case use a must clause instead of should.
I am trying to search for some keywords (eg java, hibernate, j2ee, jSP etc) in two text fields [summary and description]. Since I need to get records with any of the key words, I am using BooleanQuery
with should clause. And to search, I am using Multi-Match query. Below is my query,
The query is working fine, but I want to get records with keyword java first and then get records with other keywords. How can I achieve this?
Boosting Query: As suggested by you I used Boosting query and it
worked like charm. But, search hit count remained same even after adding
more and more terms. I am bit confused by this behavior (is my query right
?). Below is my modified query:
{
"query": {
"boosting": {
"positive": {
"multi_match": {
"query": "java",
"fields": [
"summary",
"description"
],
"type": "phrase"
}
},
"negative": {
"bool": {
"should": [
{
"multi_match": {
"query": "jsp",
"fields": [
"summary",
"description"
],
"type": "phrase"
}
},
{
"multi_match": {
"query": "servlets",
"fields": [
"summary",
"description"
],
"type": "phrase"
}
}
]
}
},
"negative_boost": 0.2
}
}
}
Added *boost *parameter: I added boost parameter to my old query and got
good results. I included boost parameter to only one search term(java).
I added boost parameter to one of the
On Tuesday, April 7, 2015 at 12:58:37 PM UTC+5:30, David Pilato wrote:
--
David
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
Le 7 avr. 2015 à 09:21, rav...@gmail.com <javascript:> a écrit :
Hi David,
Thanks for your reply. Java is not mandatory term. I want Elasticsearch to
return records having term Java first(if such records exists) followed by
records with other terms. Basically, I want to search for 2-3 keywords and
I should be able to sort results based on one of the search terms (java in
this case)
On Tuesday, April 7, 2015 at 12:17:01 PM UTC+5:30, David Pilato wrote:
You mean that Java is a mandatory term?
In that case use a must clause instead of should.
I am trying to search for some keywords (eg java, hibernate, j2ee, jSP
etc) in two text fields [summary and description]. Since I need to get
records with any of the key words, I am using *BooleanQuery *
with should clause. And to search, I am using Multi-Match query.
Below is my query,
The query is working fine, but I want to get records with keyword java
first and then get records with other keywords. How can I achieve this?
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.