Skip to content

Instantly share code, notes, and snippets.

@mattweber
Created February 15, 2012 18:54

Revisions

  1. mattweber created this gist Feb 15, 2012.
    6 changes: 6 additions & 0 deletions config
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    index:
    analysis:
    analyzer:
    string_lowercase:
    tokenizer: keyword
    filter: lowercase
    22 changes: 22 additions & 0 deletions field query
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    # does not work
    curl -XGET 'http://localhost:9200/test/type1/_search?pretty=true' -d '{
    "query":{
    "field":{
    "field1":{
    "query":"matt weber"
    }
    }
    }
    }'

    # does not work
    curl -XGET 'http://localhost:9200/test/type1/_search?pretty=true' -d '{
    "query":{
    "field":{
    "field1":{
    "query":"matt weber",
    "analyzer":"string_lowercase"
    }
    }
    }
    }'
    12 changes: 12 additions & 0 deletions mapping
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    curl -XPUT 'http://localhost:9200/test' -d '{
    "mappings" : {
    "type1" : {
    "properties" : {
    "field1" : {
    "type" : "string",
    "analyzer" : "string_lowercase"
    }
    }
    }
    }
    }'
    20 changes: 20 additions & 0 deletions query string query
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    # does not work
    curl -XGET 'http://localhost:9200/test/type1/_search?pretty=true' -d '{
    "query":{
    "query_string":{
    "query":"matt weber",
    "fields":["field1"]
    }
    }
    }'

    # does not work
    curl -XGET 'http://localhost:9200/test/type1/_search?pretty=true' -d '{
    "query":{
    "query_string":{
    "query":"matt weber",
    "fields":["field1"],
    "analyzer":"string_lowercase"
    }
    }
    }'
    1 change: 1 addition & 0 deletions test document
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    curl -XPUT 'http://localhost:9200/test/type1/1' -d '{"field1":"Matt Weber"}'
    10 changes: 10 additions & 0 deletions text query
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    # works with and without specifying the analyzer
    curl -XGET 'http://localhost:9200/test/type1/_search?pretty=true' -d '{
    "query":{
    "text":{
    "field1":{
    "query":"matt weber"
    }
    }
    }
    }'