sql icon indicating copy to clipboard operation
sql copied to clipboard

Match query is not working in sql dev tools while its working in query workbench in opensearch

Open Shivacharangoud opened this issue 3 years ago • 7 comments

SELECT * FROM contacts WHERE match(name, 'charan') ;

The above query is working in query workbench But if I use the same query in dev tools. Using plugin not working Example : POST _plugins/_sql { "query":"SELECT * FROM contacts WHERE match(name, 'charan') ;" }

The above one not working. Can any help me out with this?

Shivacharangoud avatar Aug 23 '22 04:08 Shivacharangoud

@Shivacharangoud Thanks for reporting the issue! Could you provide more details? Such as your test index, OpenSearch version etc.

dai-chen avatar Aug 23 '22 15:08 dai-chen

version:OpenSearch 1.2 POST _plugins/_sql?format=json { "query":"SELECT * FROM contacts WHERE match(name, 'charan') ;" } if i run the above script iam getting this error { "error": { "reason": "Invalid SQL query", "details": "syntax error, expect AGAINST, actual EOF", "type": "ParserException" }, "status": 400 }

Shivacharangoud avatar Aug 23 '22 17:08 Shivacharangoud

version:OpenSearch 1.2 POST _plugins/_sql?format=json { "query":"SELECT * FROM contacts WHERE match(name, 'charan') ;" } if i run the above script iam getting this error { "error": { "reason": "Invalid SQL query", "details": "syntax error, expect AGAINST, actual EOF", "type": "ParserException" }, "status": 400 }

Could you share the index mapping and some test data? Error stacktrace would be also helpful. Thanks!

dai-chen avatar Aug 23 '22 17:08 dai-chen

mappings:

{
  "contacts" : {
    "mappings" : {
      "properties" : {
        "age" : {
          "type" : "integer"
        },
        "name" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword"
            }
          }
        }
      }
    }
  }
}

available data in index:

{
  "took" : 3,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 1,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "contacts",
        "_type" : "_doc",
        "_id" : "gKrBy4IBNenCx7xvg_2M",
        "_score" : 1.0,
        "_source" : {
          "name" : "charan",
          "age" : 22
        }
      }
    ]
  }
}

Shivacharangoud avatar Aug 23 '22 17:08 Shivacharangoud

i have an question which is not related to this issues. can we add two indices using DSL on common field in opensearch? if yes how we can do it. please answer to this.

Shivacharangoud avatar Aug 23 '22 19:08 Shivacharangoud

@dai-chen Removed the old version label from this issue. Please re-tag this issue with appropriate version.

bbarani avatar Oct 20 '22 20:10 bbarani

@dai-chen Removed the old version label from this issue. Please re-tag this issue with appropriate version.

Will do. Thanks!

dai-chen avatar Oct 20 '22 21:10 dai-chen

@Shivacharangoud We've added more complete support for full text search functions including match: https://github.com/opensearch-project/sql/issues/182. Feel free to reopen if you still face this issue. Thanks!

dai-chen avatar Dec 15 '22 00:12 dai-chen

@dai-chen this seems to be broken when using JSON format type with match. CSV and standard responses work fine.

running query: SELECT * FROM test-index WHERE match(TEST_COLUMN, 'test')

getting syntax error, expect AGAINST, actual EOF

When tweaking to match MySQL standard with expected against

SELECT * FROM test-index WHERE MATCH(TEST_COLUMN) AGAINST ('test')

I am getting

err find condition class com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlMatchAgainstExpr

Any ideas?

ghost avatar Jan 10 '23 21:01 ghost

@EfChouTR From what you posted, the query was fallback to our legacy code. Just to confirm you ran each query with format=json in request URL right?

@acarbonetto Can someone help take a look? I forgot if we support relevancy search function with JSON format in v2 engine. Thanks!

dai-chen avatar Jan 10 '23 22:01 dai-chen

@EfChouTR From what you posted, the query was fallback to our legacy code. Just to confirm you ran each query with format=json in request URL right?

Correct. It will be helpful to know this ahead of time in the documentation, so we know what's supported and what isn't in each format type.

ghost avatar Jan 11 '23 14:01 ghost

JSON format in v2 engine

... isn't supported @dai-chen. You can track it in #1450

Yury-Fridlyand avatar Jun 23 '23 00:06 Yury-Fridlyand