Ask To Apps
  • Home
  • WordPress
  • Elasticsearch
  • PHP
  • Linux
  • Website Peformance

Tag : ngram

Search part of word in elasticsearch using nGram – auto-complete search

12/04/2015 Article

If we have documents of city information, in elasticsearch we can implement auto-complete search cartier nail bracelet
using nGram filter.

Add index fake cartier bracelets
mapping as following bracelets …

curl -X PUT "http://localhost:9200/cities" -d '{
"mappings" : {
"city" : {
"properties" : {
"name" : {
"type" : "string",
"search_analyzer" : "apps_search",
"index_analyzer" : "apps_index"
},
"state": {"type" : "string"},
"pin": {"type" : "string"},
"location": {"type": "geo_point"}
}
}
},
"settings" : {
"analysis" : {
"analyzer" : {
"apps_search" : {
"tokenizer" : "keyword",
"filter" : ["lowercase"]
},

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

"filter" : {
"substring" : {
"type" : "nGram",
"min_gram" : 1,
"max_gram" : 20
}
}
}
}
}';

You can search like following …

{
"size" : 100,
"query" : {
"match" : {
"name" : "a"
}
}
}

You will get result of documents with started “A”

{
"size" : 100,
"query" : {
"match" : {
"name" : "pun"
}
}
}

You will get result of documents with started as “pun”

 

Categories: Elasticsearch

Tags: autocomplete, Elasticsearch, nGram

About Author:

Appa

Recent Posts

  • Install and configure logstash-forwarder
  • Redirect request on php script through squid proxy
  • Alerting for Elasticsearch : Log watcher in elasticsearch using ES Watcher
  • Detect face from image using python script with OpenCV
  • Change mysql root password on centos
  • Search part of word in elasticsearch using nGram – auto-complete search
  • Connect VPN on centos linux using command line
  • Custom river plugin in elasticsearch
  • Backup elasticsearch with snapshot and restore api
  • PHP code to exact keywords from text.

Tags

apache Apache Lucene cache Distributed Elastic Index Elasticsearch elasticsearch performance Git Clone Git Hub Git Hub Configuration Git Hub Installation grep Import Install MySQL JSON over HTTP Linux Linux Command Linux Commands Linux search local file lsyncd md5sum Multile Domain Multisite MySQL Open Source optimization performance php performance real time search remote file Remote Git Hub remote sync RESTful Scale Schema Free Search Engine Search Index Search keyword static cache Sub Domain sync Very fast Wordpress Wordpress multisite

Copyright Ask To Apps 2022 | Proudly powered by WordPress

facebook twitter google linkedin Email Rss