elasticsearch


ElasticSearch combine must-match with multi-match


I have been trying to combine MUST-MATCH with MULTI-MATCH but couldn't get it to work. Basically I want these MUST conditions:
"must": [{ "match": { "city": $city } },
{ "match": { "is_displayed": 1 } },
{ "match": { "status": "active" } }]
and I want these matches:
"multi_match": {
"query": $query,
"type": $selectedType,
"fields": fieldArray,
}
where $query is the textbox values $selectedType is one of the multi-match query types and fieldArray is the fields to search for. For example, when the text box value is "hello world" and fieldArray is ['title', 'cuisine'], either "hello" and/or "world" must match either or all of the specified fields. Any insight and advice is appreciated.
I guess adding another clause in must block will do the needful.
{
"query": {
"bool": {
"must": [
{
"match": {
"city": "$city"
}
},
{
"match": {
"is_displayed": 1
}
},
{
"match": {
"status": "active"
}
},
"query_string": {
"fields": fieldArray,
"query": "*$query*"
}
}
]
}
}
}

Related Links

Return parent data with child document from Elasticsearch
Elasticsearch Giving Incorrect Result When Using “must_not” operator alongwith “must” Operator
ElasticSearch _suggest queries are case sensitive. Want them to be case insensitive
How to normalize periods in elastic search query (such that JJ Abrams == J.J Abrams)?
Elastic Search - Sort By Doc Type
ElasticSearch Filtering aggregations from array field
Full text search for exact match_phrase (with leading and trailing whitespace) in elasticsearch
Do two equal documents in elasticsearch double the needed disc space
In logstash/ElasticSearch/Kibana, how do I augment records following a particular stateful request?
How to know which shard is overloaded in Elasticsearch?
ElasticSearch - searching different doc_types with the same field name but different analyzers
ELK Type Conversion - Not a number but a string
How to get the definitiion of a search analyzer of an index in elasticsearch
ElasticSearch query using match or term?
How to combine aggregations in ElasticSearch/Kibana?
ElasticSerach cluster performance

Categories

HOME
openshift
libgdx
devexpress
ant
jersey-2.0
header
moodle-api
drag-and-drop
google-search-console
firebase-dynamic-links
scheduler
tup
cqrs
slide
lapack
erd
powermock
trace32
renderscript
scheduled-tasks
deepfreeze
parceler
libgit2
quantitative-finance
perfino
jpa-2.1
pubxml
cellular-network
xdebug
msdeploy
android-service
ruby-daemons
math.js
laravel-4.2
mongoengine
image-optimization
keyboard-layout
djcelery
identify
django-crispy-forms
ms-dos
strapi
best-buy-api
imgur
grunt-contrib-watch
react-intl
audio-converter
bit-shift
webalizer
ol3-google-maps
beeline
nusoap
cordova-ios
htmlspecialchars
android-mediarecorder
wikimapia
dtd
http4s
oracle-fusion-apps
deviare
logical
jpda
fuzzer
right-to-left
xcopy
persistent-object-store
teamviewer
i2b2
smart-tv
stack-smash
highest
uitest
ocmockito
ildasm
zend-mail
xml-signature
forceclose
jomsocial
pbkdf2
vlab
insertonsubmit
pacman
dibs
arel
itunes-sdk
xalan
word-frequency
flymake
exponent
navigationcontroller
microblogging
will-paginate
data-dump
office-automation
space-partitioning
nosetests
page-curl
directshow.net
webresponse
tabbarcontroller
.net-services
html-components
accumulator
account-management

Resources

Encrypt Message