It sounds like completion suggest may not be exactly what you want. One way
you could solve your problem is to use a shingle (ngram) analyzer in your
mapping, combined with a prefix query. A description of the basic technique
can be found here:
http://developer.rackspace.com/blog/qbox.html#.UZ0yEWRATQ4

Qbox has a demo (here:
http://be6c2e3260c3e2af000.qbox.io/_plugin/demo/tablemap/index.html) that
uses this technique for auto-complete. Queries are matched using a prefix
query, against a field that has been analyzed using a shingle filter.

So, adapted to the information you've given, a solution might look like
this:

Create the index with the following analyzer:

curl -XPUT http://[endpoint]/[index_name]
{
   "settings": {
      "analysis": {
         "filter": {
            "shingle_filter": {
               "type": "shingle",
               "min_shingle_size": 2,
               "max_shingle_size": 5
            }
         },
         "analyzer": {
            "shingle_analyzer": {
               "type": "custom",
               "tokenizer": "standard",
               "filter": [
                  "lowercase",
                  "shingle_filter"
               ]
            }
         }
      }
   }
}

and then apply this mapping:

curl -XPUT http://[endpoint]/[index_name]/titles/_mapping
{
   "titles": {
        "properties": {
            "DOC_ID": {
                "type":"string"
            },
            "TITLE": {
                "type": "string",
                "index_analyzer": "shingle_analyzer"
            }
        }
    }
}

once you have some documents indexed you can query with "on" using the
following query structure

http://[endpoint]/_search
{
   "query": {
      "prefix": {
                  "TITLE": "on"
               }
   }
}

This should give you the behavior you are looking for.







-----
Co-Founder and CTO, StackSearch, Inc. 
Hosted Elasticsearch at http://qbox.io
--
View this message in context: 
http://elasticsearch-users.115913.n3.nabble.com/ElasticSearch-Auto-Completion-and-Term-Phrase-Suggesters-tp4046703p4046758.html
Sent from the ElasticSearch Users mailing list archive at Nabble.com.

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/1388279720679-4046758.post%40n3.nabble.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to