NLPchina / elasticsearch-sql

Use SQL to query Elasticsearch
Apache License 2.0
6.99k stars 1.54k forks source link

elasticsearch q=query problem #910

Open mhsankar opened 5 years ago

mhsankar commented 5 years ago

Hi I have a problem when i search for example q=query('name:hadi') it work very good. but when i search q=query('name: hadi ali') it search in all field hadi or ali if so i want to search hadi or ali in name field. how can solve it?

shi-yuan commented 5 years ago

q=query('name:(hadi ali)')

mhsankar commented 5 years ago

Thanks i explain this query with site server in your page. i saw fields are empty. how can set fields in q=query() ?

shi-yuan commented 5 years ago
SELECT * FROM myindex WHERE q=query('hadi ali', fields='name,name2^10')
pankajmalkani commented 5 years ago

how to write nested query for example "select * from myindex where q=query("hadi ali', fields="nested(field.id),nested(field.name"))

shi-yuan commented 5 years ago

https://github.com/NLPchina/elasticsearch-sql/wiki/NestedTypes-queries

palbiplab commented 4 years ago

Explain of SELECT * FROM myindex WHERE q=query('hadi ali', fields='name,name2^10') Returns fields as [] which is not expected. i am using es 6.4.2. Does it work in later version?

Note: default_field works

shi-yuan commented 4 years ago

branch master:

{
  "from": 0,
  "size": 1000,
  "query": {
    "bool": {
      "filter": [
        {
          "bool": {
            "must": [
              {
                "query_string": {
                  "query": "hadi ali",
                  "fields": [
                    "name^1.0",
                    "name2^10.0"
                  ],
                  "type": "best_fields",
                  "default_operator": "or",
                  "max_determinized_states": 10000,
                  "enable_position_increments": true,
                  "fuzziness": "AUTO",
                  "fuzzy_prefix_length": 0,
                  "fuzzy_max_expansions": 50,
                  "phrase_slop": 0,
                  "escape": false,
                  "auto_generate_synonyms_phrase_query": true,
                  "fuzzy_transpositions": true,
                  "boost": 1
                }
              }
            ],
            "adjust_pure_negative": true,
            "boost": 1
          }
        }
      ],
      "adjust_pure_negative": true,
      "boost": 1
    }
  }
}