Skip to content

Instantly share code, notes, and snippets.

@Signum
Created November 28, 2013 17:36
Show Gist options
  • Save Signum/7695611 to your computer and use it in GitHub Desktop.
Save Signum/7695611 to your computer and use it in GitHub Desktop.
Trying to get phrase suggest ("did you mean") queries working
Example document:
{
_index: debshots
_type: jdbc
_id: 15808
_version: 172
_source: {
description: Children's game based on the "memory" card game
name: lmemory
}
}
Input (trying to get a suggestion for the "card game" query):
curl -s -XPOST 'torf:9200/debshots/jdbc/_search' -d '{
"suggest" : {
"text" : "card game",
"simple_phrase" : {
"phrase" : {
"analyzer" : "simple",
"field" : "description"
}
}
}
}'
Output (that does not contain anything like "card game" for some reason)
{
"hits" : {
"hits" : [
{
"_source" : {
"name" : "libswe-doc",
"description" : "documentation for the libswe package"
},
"_score" : 1,
"_index" : "debshots",
"_id" : "91735",
"_type" : "jdbc"
},
{
"_source" : {
"name" : "libswscale2",
"description" : "Libav video scaling library"
},
"_score" : 1,
"_index" : "debshots",
"_id" : "79468",
"_type" : "jdbc"
},
{
"_source" : {
"name" : "libswscale-dev",
"description" : "Development files for libswscale"
},
"_score" : 1,
"_index" : "debshots",
"_id" : "73444",
"_type" : "jdbc"
},
{
"_source" : {
"name" : "libswscale-extra-2",
"description" : "Libav video scaling library"
},
"_score" : 1,
"_index" : "debshots",
"_id" : "99344",
"_type" : "jdbc"
},
{
"_source" : {
"name" : "libswtchart-java",
"description" : "Chart drawing SWT component"
},
"_score" : 1,
"_index" : "debshots",
"_id" : "109783",
"_type" : "jdbc"
},
{
"_source" : {
"name" : "libswtchart-java-doc",
"description" : "Chart drawing SWT component (documentation)"
},
"_score" : 1,
"_index" : "debshots",
"_id" : "109773",
"_type" : "jdbc"
},
{
"_source" : {
"name" : "libsvnkit-java",
"description" : "pure Java Subversion client library"
},
"_score" : 1,
"_index" : "debshots",
"_id" : "108810",
"_type" : "jdbc"
},
{
"_source" : {
"name" : "libsvnkit-java-doc",
"description" : "documentation for libsvnkit-java"
},
"_score" : 1,
"_index" : "debshots",
"_id" : "105862",
"_type" : "jdbc"
},
{
"_source" : {
"name" : "libsword-common",
"description" : "common settings and module repository for libsword"
},
"_score" : 1,
"_index" : "debshots",
"_id" : "96105",
"_type" : "jdbc"
},
{
"_source" : {
"name" : "libsword-dbg",
"description" : "API/library for bible software - Debug Files"
},
"_score" : 1,
"_index" : "debshots",
"_id" : "105614",
"_type" : "jdbc"
}
],
"max_score" : 1,
"total" : 43682
},
"timed_out" : false,
"suggest" : {
"simple_phrase" : [
{
"length" : 9,
"options" : [],
"text" : "card game",
"offset" : 0
}
]
},
"_shards" : {
"failed" : 0,
"successful" : 1,
"total" : 1
},
"took" : 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment