elasticsearch


quey_string search is not working as expected


Suppose We have data :-
{ "_id" : "1","name" : "Doeman John"}
{"_id" : "2","name" : "John"}
Query Used :-
{
"query": {
"query_string": {
"fields" : ["name"] ,
"query": "John"
}
}
}
Actual result :-
{ "_id" : "1","name" : "Doeman John"}
{"_id" : "2","name" : "John"}
Expected result :-
{"_id" : "2","name" : "John"}
I am using Standard Analyzer . Could I achieve my expected result without changing any Analyzer setting ?
You can not achieve this without changing analyzer settings.
In case you still want to use Standard Analyzer, you can make your field multifield.
{
"mappings": {
"my_type": {
"properties": {
"name": {
"type": "text",
"fields": {
"raw": {
"type": "keyword"
}
}
}
}
}
}
}
and then run your query on the not_analyzed version.
{
"query": {
"term": {
"name.raw": {
"value": "John"
}
}
}
}
This will fetch results as per your requirement.
`

Related Links

Adding additional fields to ElasticSearch terms aggregation
ElasticSearch multi_match if field exists apply filter otherwise dont worry about it?
ElasticSearch Date Histogram Interval
Kibana 4 index patterns time-field
elasticsearch: Did I lose data when two of my three nodes went down?
ElasticSearch automatic typing
how to copy ElasticSearch field to another field
ElasticSearch Order after 2 term aggregation
Mapping openNLP or StanfordNLP in elasticsearch
An Elasticsearch filter to determine the absence of a value
Different behaviour in elasticsearch with two different indexes
Elasticsearch 2.0: _id is not configurable
what will happen when one of ElasticSearch server down
How to get the total size of data matching query ElasticSearch?
Which is Better when you use Java to query in Elastic Search, Java API or passing the JSON string to setQuery?
ElasticSearch 2.0 Java API: java.lang.ClassNotFoundException: org.elasticsearch.common.settings.ImmutableSettings$Builder

Categories

HOME
ionic2
events
matrix
jms
antd
hid
kivy
initialization
google-play-services
vue-resource
fedora
azure-logic-apps
getopenfilename
bootstrap-switch
pm2
exe
fosuserbundle
playframework-2.0
significance
social-tables
device
fusetools
hdmi
xdebug
macromedia
intune
dotcms
matlab-app-designer
phpstorm-2016.1
progid
opnet
actframework
spring-rabbitmq
cups
formsauthenticationticket
variable-variables
ng-repeat
llvm-ir
imgur
export-to-pdf
resampling
klee
virtual-memory
nomad
linq-to-excel
visual-format-language
maven-jaxb2-plugin
android-sharing
watir-webdriver
gnome-terminal
portability
predicates
google-shopping-api
oracle-fusion-apps
pjax
libharu
svnserve
yii2-model
apache-pig-grunt
jsr363
linuxbrew
in-app-billing
stack-smash
canopy
alwayson
physicsjs
scala-macros
rebar
tabris
relationships
nidaqmx
lumia-imaging-sdk
forio-contour
hyperloglog
fileshare
lsa
boinc
libxml-js
acceptance-testing
jbox2d
session-0-isolation
user-forums
multiscaleimage
coordinate
kobold2d
series-40
opends
prototypal-inheritance
glx
infopath-2007
will-paginate
server-variables
azure-acs
rtd
dm
spring-modules
ning

Resources

Encrypt Message