Non-prefix-based Completion Suggester


(Milenko Zahovic) #1

I have my mapping type as follows:

{
  "mappings": {
    "book": {
      "properties": {
        "title": {
          "type": "completion"
        }
      }
    }
  }
}

and index a data:

{"create": {"_index": "library", "_type": "book", "_id": 1}}
{"id": 1, "title": "C++ How to Program"}

my question is how do i get document with id 1 of type book if my query is like this:

POST /library/book/_search
{
	"suggest": {
		"book-suggest": {
			"text": "program C++",
			"completion": {
				"field": "title"
			}
		}
	}
}

(Jimferenczi) #2

The completion suggester is prefix-based so partial match on the first and last term is not possible. Why do you need a completion field ? You could use a simple text field and use a match query instead ? This would be slower but much more flexible in terms of matching.


(Milenko Zahovic) #3

Need completion just for the speed. Thank you for the explanation.


(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.