Skip to content

Instantly share code, notes, and snippets.

@briandilley
Created May 7, 2013 05:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save briandilley/5530387 to your computer and use it in GitHub Desktop.
Save briandilley/5530387 to your computer and use it in GitHub Desktop.
endgeNGram problem
mapping
=================
{
"analysis": {
"analyzer": {
"username_index": {
"tokenizer": "keyword",
"filter": ["lowercase", "username_ngram"]
},
"username_search": {
"tokenizer": "keyword",
"filter": ["lowercase"]
}
},
"filter": {
"username_ngram": {
"type": "edgeNGram",
"side" : "front",
"min_gram": 1,
"max_gram": 15
}
}
}
}
mapping
=================
{
"user_follow": {
"properties": {
"targetId": { "type": "string", "store": true },
"followerId": { "type": "string", "store": true },
"dateUpdated": { "type": "date", "store": true },
"userName": {
"type": "multi_field",
"fields": {
"userName": {
"type": "string",
"index": "not_analyzed"
},
"autocomplete": {
"type": "string",
"index_analyzer": "username_index",
"search_analyzer": "username_search"
}
}
}
}
}
}
search:
===========
{
"from" : 0,
"size" : 50,
"query" : {
"bool" : {
"must" : [ {
"field" : {
"targetId" : "51888c1b04a6a214e26a4009"
}
}, {
"match" : {
"userName.autocomplete" : {
"query" : "brian",
"type" : "boolean"
}
}
} ]
}
},
"fields" : "followerId"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment