How can I get the string Suggeter actually hit, in the Elasticsearch 1.7 , somebody write this ,pls help


(minghua.cao) #1

for example:

  1. I create my mapping --
    curl -X PUT localhost:9200/music
    curl -X PUT localhost:9200/music/song/_mapping -d '{
    "song" : {
    "properties" : {
    "name" : { "type" : "string" },
    "suggest" : { "type" : "completion",
    "analyzer" : "simple",
    "search_analyzer" : "simple",
    "payloads" : true
    }
    }
    }
    }'

  2. Then I index this suggest text --
    curl -X PUT 'localhost:9200/music/song/1?refresh=true' -d '{
    "name" : "Nevermind",
    "suggest" : {
    "input": [ "Nevermind", "Nirvana"],
    "output": "000010000",
    "payload" : { "artistId" : 2321 },
    "weight" : 34
    }
    }'

  3. Search it by
    curl -X POST 'localhost:9200/music/_suggest?pretty' -d '{
    "song-suggest" : {
    "text" : "niverm",
    "completion" : {
    "field" : "suggest",
    "fuzzy" : {
    "fuzziness" : 2,
    "unicode_aware" :true
    }
    }
    }
    }'

--Now I need to get the exact string i my query hit . ( "niverm" hit the "Neverm" --prefix of "Nevermind", I need to get the "Neverm" to check it if it match my rules, if not match my rules , this term related suggest will not in my response option)


(system) #2