what happens when you query  as you indicated ?

did you try and wildchar query ? Also perhaps  an analyzer with the shingle 
token filter 
(http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/analysis-shingle-tokenfilter.html#analysis-shingle-tokenfilter)
 
will work better for your purposes ?

Ramdev


On Wednesday, 30 April 2014 09:15:35 UTC-5, Kruti Shukla wrote:
>
> Posted same question on "stackover flow" 
> "http://stackoverflow.com/questions/23244796/substring-match-in-search-term-order-using-elasticsearch";
>  but still looking for Answer.
>
>
> I'm new to elasticsearch
>
> I want to perform substring/partial word match using elastic search. I 
> want results to be returned in the perticular order. In order to explain my 
> problem I will show you how I create my index, mappings and what are the 
> records I use.
>
> *Creating Index and mappings:*
>
> PUT /my_index1
> {
>     "settings": {
>         "analysis": {
>             "filter": {
>                 "trigrams_filter": {
>                     "type":     "ngram",
>                     "min_gram": 3,
>                     "max_gram": 3
>                 }
>             },
>             "analyzer": {
>                 "trigrams": {
>                     "type":      "custom",
>                     "tokenizer": "standard",
>                     "filter":   [
>                         "lowercase",
>                         "trigrams_filter"
>                     ]
>                 }
>             }
>         }
>     },
>     "mappings": {
>         "my_type1": {
>             "properties": {
>                 "text": {
>                     "type":     "string",
>                     "analyzer": "trigrams" 
>                 }
>             }
>         }
>     }
> }
>
> *Bulk record insert:*
>
> POST /my_index1/my_type1/_bulk
> { "index": { "_id": 1 }}
> { "text": "men's shaver" }
> { "index": { "_id": 2 }}
> { "text": "men's foil shaver" }
> { "index": { "_id": 3 }}
> { "text": "men's foil advanced shaver" }
> { "index": { "_id": 4 }}
> { "text": "norelco men's foil advanced shaver" }
> { "index": { "_id": 5 }}
> { "text": "men's shavers" }
> { "index": { "_id": 6 }}
> { "text": "women's shaver" }
> { "index": { "_id": 7 }}
> { "text": "women's foil shaver" }
> { "index": { "_id": 8 }}
> { "text": "women's foil advanced shaver" }
> { "index": { "_id": 9 }}
> { "text": "norelco women's foil advanced shaver" }
> { "index": { "_id": 10 }}
> { "text": "women's shavers" }
>
> *Now, I want to perform search for "en's shaver". I'm searching using 
> follwing query:*
>
> POST /my_index1/my_type1/_search
> {
>     "query": {
>        "match": {
>           "text": 
>           { "query": "en's shaver",
>
>             "minimum_should_match": "100%"
>
>           }
>        }
>
>     }
> }
>
> I want results to be in following sequence:
>
>    1. men's shaver --> closest match with following same search keyword 
>    order "en's shaver
>    2. women's shaver --> closest match with following same search keyword 
>    order "en's shaver
>    3. men's foil shaver --> increased distance by 1
>    4. women's foil shaver --> increased distance by 1
>    5. men's foil advanced shaver --> increased distance by 2
>    6. women's foil advanced shaver --> increased distance by 2
>    7. men's shavers --> substring match for "shavers"
>    8. women's shavers --> substring match for "shavers"
>
> I'm performing following query. It is not giving me result in the order I 
> want:
>
> POST /my_index1/my_type1/_search
> {
>    "query": {
>       "query_string": {
>          "default_field": "text",
>          "query": "men's shaver",
>          "minimum_should_match": "90%"
>       }
>    }
> }
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/df570460-9e71-4c4b-9208-c5a7f467cde5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to