Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-4232

Elasticsearch IN Query is not supported

    XMLWordPrintableJSON

Details

    Description

      IN clause is required in multiple queries to fetch  documents that contain more than one exact terms in a provided field.

      SQL Query

      name IN ("kimchy", "james")

       RelNode for same-

      rexb.makeCall(SqlStdOperatorTable.IN, builder.field("name"), rexb.makeLiteral("kimchy"), rexb.makeLiteral("james"))

       

        Problem : Calcite for above RelNode throws

      java.sql.SQLException : Error while preparing statement [null]

      Suppressed: java.lang.UnsupportedOperationException: Can't handle partial QueryExpression: org.apache.calcite.adapter.elasticsearch.PredicateAnalyzer$CompoundQueryExpression@3e782f91
      at org.apache.calcite.adapter.elasticsearch.PredicateAnalyzer.analyze(PredicateAnalyzer.java:114)
      at org.apache.calcite.adapter.elasticsearch.ElasticsearchFilter$PredicateAnalyzerTranslator.translateMatch(ElasticsearchFilter.java:99)
      at org.apache.calcite.adapter.elasticsearch.ElasticsearchFilter.implement(ElasticsearchFilter.java:64)
      at org.apache.calcite.adapter.elasticsearch.ElasticsearchRel$Implementor.visitChild(ElasticsearchRel.java:140)
      at org.apache.calcite.adapter.elasticsearch.ElasticsearchProject.implement(ElasticsearchProject.java:59)

      Expected Elasticsearch Query - 

      GET /_search
      {
        "query": {
          "terms": {
            "name": [
              "kimchy",
              "james"
            ]
          }
        }
      }
      

      Solution: Extend IN SQLTableOperator support in elasticsearch adapters to use Terms Query Builder which is already present in elasticsearch adapters.

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            shlok7296 Shlok Srivastava
            Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 2h 20m
                2h 20m