@Tushar_Mudgal , i try to explain how does it work:
- when you insert data to elasticsearch
for example word : "astro-ph"
this word by default divide into 2 term: "astro" and "ph"
to your index applied "standard-analyzer"
so you can use:
- term query to find documents with terms
curl -H "Content-type: application/json" localhost:9200/_search -d '{
"query" : { "term" : { "primary_category" : "astro" } } }'
and as result you get all documents that contains term "astro":
{"took":19,"timed_out":false,"_shards":{"total":30,"successful":30,"skipped":0,"failed":0},"hits":{"total":3,"max_score":0.2876821,"hits":[{"_index":"test","_type":"doc","_id":"ntlDt2YBOyk1S2R0H33v","_score":0.2876821,"_source":{
"primary_category" : "hello astro-ph. and bye"
}},{"_index":"test","_type":"doc","_id":"m9lCt2YBOyk1S2R0_31C","_score":0.2876821,"_source":{
"primary_category" : "astro-ph"
}},{"_index":"test","_type":"doc","_id":"ndlDt2YBOyk1S2R0H33S","_score":0.2876821,"_source":{
"primary_category" : "astro-ph.EP"
- or use match query
curl -H "Content-type: application/json" localhost:9200/_search -d '{
"query" : {
"match" : {
"primary_category" : "astro-ph"
}
}
}'
and result:
{"took":5,"timed_out":false,"_shards":{"total":30,"successful":30,"skipped":0,"failed":0},"hits":{"total":3,"max_score":0.5753642,"hits":[{"_index":"test","_type":"doc","_id":"ntlDt2YBOyk1S2R0H33v","_score":0.5753642,"_source":{
"primary_category" : "hello astro-ph. and bye"
}},{"_index":"test","_type":"doc","_id":"m9lCt2YBOyk1S2R0_31C","_score":0.5753642,"_source":{
"primary_category" : "astro-ph"
}},{"_index":"test","_type":"doc","_id":"ndlDt2YBOyk1S2R0H33S","_score":0.2876821,"_source":{
"primary_category" : "astro-ph.EP"