Last active
December 21, 2015 09:49
-
-
Save dadoonet/6287562 to your computer and use it in GitHub Desktop.
Trying Suggest API on multifields
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -XDELETE "http://localhost:9200/test?pretty" | |
curl -XPOST "http://localhost:9200/test?pretty" -d '{ | |
"settings": { | |
"index": { | |
"number_of_shards": 1, | |
"number_of_replicas": 0, | |
"analysis":{ | |
"analyzer":{ | |
"suggest":{ | |
"type": "custom", | |
"tokenizer": "standard", | |
"filter": [ "standard", "lowercase", "suggest_shingle" ] | |
} | |
}, | |
"filter":{ | |
"suggest_shingle":{ | |
"type": "shingle", | |
"min_shingle_size": 2, | |
"max_shingle_size": 5, | |
"output_unigrams": true | |
} | |
} | |
} | |
} | |
} | |
}' | |
curl -XPOST "http://localhost:9200/test/test/_mapping?pretty" -d '{ | |
"test": { | |
"properties" : { | |
"title": { | |
"path": "just_name", | |
"type": "multi_field", | |
"fields": | |
{ | |
"title": { | |
"type": "string" | |
}, | |
"suggest": { | |
"type": "string", | |
"index": "analyzed", | |
"similarity": "BM25", | |
"analyzer": "suggest" | |
} | |
} | |
} | |
} | |
} | |
}' | |
curl -XPOST "http://localhost:9200/test/test?pretty" -d '{ | |
"title": "Just testing the suggestions api" | |
}' | |
curl -XPOST "http://localhost:9200/test/test?pretty&refresh" -d '{ | |
"title": "An other title" | |
}' | |
curl -XGET "http://localhost:9200/test/test/_search?pretty" -d '{ | |
"suggest": { | |
"text": "tetsting sugestion", | |
"phrase":{ | |
"phrase":{ | |
"field": "suggest", | |
"max_errors": 5 | |
} | |
} | |
} | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Your mapping was incorrect - bad indentation. Also you shouldn't use
just_name
in this case.Try this: