Skip to content

Instantly share code, notes, and snippets.

@koh110
Last active June 13, 2020 18:11
Show Gist options
  • Save koh110/32b6a225ef3329a5f04476d73898b53a to your computer and use it in GitHub Desktop.
Save koh110/32b6a225ef3329a5f04476d73898b53a to your computer and use it in GitHub Desktop.
Elasticsearch
# index 確認
$ curl -X GET 'localhost:9200/_cat/indices?v'

$ curl -X DELETE 'localhost:9200/index-rooms-v1?pretty'

$ curl -X POST -H 'Content-Type: application/json' 'http://localhost:9200/rooms/_analyze?pretty' -d '{"analyzer": "ngram", "text": "general"}'

$ curl -X POST -H 'Content-Type: application/json' "http://localhost:9200/rooms/_search?pretty=true" -d '
{
  "query" : {
    "bool": {
      "must": [
        { "match": { "status": 1 } },
        {
          "bool": {
            "should": [
              {
                "simple_query_string": {
                  "query": "ge",
                  "fields": ["name.kuromoji"],
                  "default_operator": "and"
                }
              }
            ]
          }
        }
      ]
    }
  }
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment