Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 7.1
    • Component/s: None
    • Security Level: Public (Default Security Level. Issues are Public)
    • Labels:
      None

      Description

      It will be great if Solr has a powerful query DSL. This ticket is an extension of http://yonik.com/solr-json-request-api/.

      Here are several examples of Query DSL

      curl -XGET http://localhost:8983/solr/query -d '
      {
          "query" : {
              "lucene" : {
                  "df" : "content",
                  "query" : "solr lucene"
              }
          }
      }
      

      the above example can be rewritten as (because lucene is the default qparser)

      curl -XGET http://localhost:8983/solr/query -d '
      {
          "query" : "content:(solr lucene)"
      }
      

      more complex example:

      curl -XGET http://localhost:8983/solr/query -d '
      { 
          "query" : {
              "boost" : {
                  "query" : {
                      "lucene" : {
                          "q.op" : "AND",
                          "df" : "cat_s",
                          "query" : "A"
                      }
                  }
                  "b" : "log(popularity)"
              }
          }
      }
      

      I call it Json Query Object (JQO) and It defined as :

      • It can be a valid query string for Lucene query parser, for example : "title:solr"
      • It can be a valid local parameters string, for example : " {!dismax qf=myfield}

        solr rocks"

      • It can be a json object with structure like this
        {
          "query-parser-name" : {
             "param1" : "value1",
             "param2" : "value2",
             "query" : <JQO>,
             "another-param" : <JQO>
          }
        }
        

        Therefore the above dismax query can be rewritten as ( be noticed that the query argument in local parameters, is put as value of query field )

        {
          "dismax" : {
             "qf" : "myfield"
             "query" : "solr rocks"
          }
        }
        

      I will attach an HTML, contain more examples of Query DSL.

        Attachments

        1. Solr Query DSL - examples.html
          78 kB
          Cao Manh Dat
        2. SOLR-11244.patch
          10 kB
          Cao Manh Dat
        3. SOLR-11244.patch
          14 kB
          Cao Manh Dat
        4. SOLR-11244.patch
          16 kB
          Cao Manh Dat
        5. SOLR-11244.patch
          17 kB
          Cao Manh Dat

          Issue Links

            Activity

              People

              • Assignee:
                caomanhdat Cao Manh Dat
                Reporter:
                caomanhdat Cao Manh Dat
              • Votes:
                2 Vote for this issue
                Watchers:
                13 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: