java - Like search in Elasticsearch -


i using elasticsearch filtering , searching json file , newbie in technology. little bit confused how write query in elasticsearch.

select * table_name 'field_name' 'a%' 

this mysql query. how write query in elasticsearch? using elasticsearch version 0.90.7.

i highly suggest updating elasticsearch version if possible, there have been significant changes since 0.9.x.

this question not quite specific enough, there many ways elasticsearch can fulfill functionality, , differ on overall goal. if looking replicate sql query in case use wildcard query or prefix query.

using wildcard query:

note: careful wildcard searches, slow. avoid using wildcards @ beginning of strings.

get /my_index/table_name/_search {     "query": {         "wildcard": {             "field_name": "a*"         }     } } 

or prefix query

get /my_index/table_name/_search {     "query": {         "prefix": {             "field_name": "a"         }     } } 

or partial matching:

note: not blindly use partial matching, while there corner cases it's use, correct use of analyzers better.

also exact query equivalent like '%a%', again, better setup correct use of mapping , normal query search!

get /my_index/table_name/_search {     "query": {         "match_phrase": {             "field_name": "a"         }     } } 

if reading wondering querying es search-as-you-type suggest reading on edge-ngrams, relate proper use of mapping depending on attempting =)


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -