Elastic search : EdgeGram, prefix, suffix

How one can search a word through its middle or last letters. For example
CORPORATION is a words and I am able to search CORPORATION with its
initials like COR, CO, C etc by using EdgeGram and prefix filter. but I am
not able to search it with last letters or middle letters of CORPORATION
that is POR or RATI or ION. is elastic search support this features? if yes
then please help me how can I resolve this issue.

EdgeGram Mapping and Setting:

curl -X PUT "http://192.168.1.15:9200/catalog" -d '{
"mappings" : {
"product" : {
"properties" : {
"title" : {
"type" : "string",
"search_analyzer" : "str_search_analyzer",
"index_analyzer" : "str_index_analyzer"
}
}
}
},

"settings" : {
"analysis" : {
"analyzer" : {
"str_search_analyzer" : {
"tokenizer" : "keyword",
"filter" : ["lowercase"]
},

    "str_index_analyzer" : {
      "tokenizer" : "keyword",
      "filter" : ["lowercase", "substring"]
    }
  },

  "filter" : {
    "substring" : {
      "type" : "edgeNGram",
      "min_gram" : 1,
      "max_gram"  : 20
    }
  }
}

}
}'

Inserting Value :

curl -X PUT "http://192.168.1.15:9200/catalog/product/1" -d '{
"title" : "CORPORATION"
}'

Search Query initials of* COR*PORATION “COR":

curl "http://192.168.1.15:9200/catalog/product/_search?pretty=1" -d '{
"query" : {
"text" : {
"title" : "COR"
}
}
}'

Output:

{
"took" : 98,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 0.076713204,
"hits" : [ {
"_index" : "catalog",
"_type" : "product",
"_id" : "1",
"_score" : 0.076713204, "_source" : {
"title" : "CORPORATION"
}
} ]
}
}

Second query : middle letters of CORPORATION "POR"

curl "http://192.168.1.15:9200/catalog/product/_search?pretty=1" -d '{
"query" : {
"text" : {
"title" : "POR"
}
}
}'

output:

{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}

Third query : last letters of CORPORATION "TION"

curl "http://192.168.1.15:9200/catalog/product/_search?pretty=1" -d '{
"query" : {
"text" : {
"title" : "TION"
}
}
}'
output:
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

I think i answered yesterday. Use ngram, not EdgeNGram.

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 7 févr. 2013 à 12:25, Mohit Kumar Yadav mohit.kumar.ngi@gmail.com a écrit :

How one can search a word through its middle or last letters. For example CORPORATION is a words and I am able to search CORPORATION with its initials like COR, CO, C etc by using EdgeGram and prefix filter. but I am not able to search it with last letters or middle letters of CORPORATION that is POR or RATI or ION. is elastic search support this features? if yes then please help me how can I resolve this issue.

EdgeGram Mapping and Setting:

curl -X PUT "http://192.168.1.15:9200/catalog" -d '{
"mappings" : {
"product" : {
"properties" : {
"title" : {
"type" : "string",
"search_analyzer" : "str_search_analyzer",
"index_analyzer" : "str_index_analyzer"
}
}
}
},

"settings" : {
"analysis" : {
"analyzer" : {
"str_search_analyzer" : {
"tokenizer" : "keyword",
"filter" : ["lowercase"]
},

    "str_index_analyzer" : {
      "tokenizer" : "keyword",
      "filter" : ["lowercase", "substring"]
    }
  },

  "filter" : {
    "substring" : {
      "type" : "edgeNGram",
      "min_gram" : 1,
      "max_gram"  : 20
    }
  }
}

}
}'

Inserting Value :

curl -X PUT "http://192.168.1.15:9200/catalog/product/1" -d '{
"title" : "CORPORATION"
}'

Search Query initials of CORPORATION “COR":

curl "http://192.168.1.15:9200/catalog/product/_search?pretty=1" -d '{
"query" : {
"text" : {
"title" : "COR"
}
}
}'

Output:

{
"took" : 98,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 0.076713204,
"hits" : [ {
"_index" : "catalog",
"_type" : "product",
"_id" : "1",
"_score" : 0.076713204, "_source" : {
"title" : "CORPORATION"
}
} ]
}
}

Second query : middle letters of CORPORATION "POR"

curl "http://192.168.1.15:9200/catalog/product/_search?pretty=1" -d '{
"query" : {
"text" : {
"title" : "POR"
}
}
}'

output:

{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}

Third query : last letters of CORPORATION "TION"

curl "http://192.168.1.15:9200/catalog/product/_search?pretty=1" -d '{
"query" : {
"text" : {
"title" : "TION"
}
}
}'
output:
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}

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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.