Re: Substring match in search term order using Elasticsearch

2014-05-01 Thread Kruti Shukla
For following query: 
POST /my_index1/my_type1/_search

{
"query": {
   "match": {
  "text": 
  { "query": "en's shaver",

"minimum_should_match": "100%"

  }
   }

}
}

I'm getting this result set -->
women's shaver
men's foil advanced shaver
women's foil advanced shaver
men's foil shaver
women's foil shaver
norelco men's foil advanced shaver
norelco women's foil advanced shaver
men's shavers

And when I search using below query:

POST /my_index1/my_type1/_search
{
   "query": {
  "query_string": {
 "default_field": "text",
 "query": "men's shaver",
 "minimum_should_match": "90%"
  }
   }
}

I'm getting this result set -->
women's shavers
men's shaver
women's shaver
men's foil advanced shaver
women's foil advanced shaver
men's foil shaver
women's foil shaver
norelco men's foil advanced shaver
norelco women's foil advanced shaver
men's shavers

Which is not correct either. 

I think shigles will not help when I want to search by substring for 
example "en's" shaver.
If you think it can help then can you please post some code that I can give 
me above result using shigle?

On Wednesday, April 30, 2014 3:04:03 PM UTC-4, Ramdev Wudali wrote:
>
> 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<http://www.google.com/url?q=http%3A%2F%2Fwww.elasticsearch.org%2Fguide%2Fen%2Felasticsearch%2Freference%2Fcurrent%2Fanalysis-shingle-tokenfilter.html%23analysis-shingle-tokenfilter&sa=D&sntz=1&usg=AFQjCNGpdJVjC70Brm5eG5zM9E3UNELkJQ>)
>  
> 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 }}
>> {

Re: Substring match in search term order using Elasticsearch

2014-04-30 Thread Ramdev Wudali
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 elasticsearch+unsubscr...@googlegroups.com.
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.


Substring match in search term order using Elasticsearch

2014-04-30 Thread Kruti Shukla


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 elasticsearch+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/b7d43a2d-be99-45a5-a2a3-4151dbc52292%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.