1

Grails ElasticSearch プラグインを使用しており、次のクエリを使用したいと考えています。

"bool" : {
    "must" : {
        "term" : { "user" : "kimchy" }
    },
    "must_not" : {
        "range" : {
            "age" : { "from" : 10, "to" : 20 }
        }
    },
    "should" : [
        {
            "term" : { "tag" : "wow" }
        },
        {
            "term" : { "tag" : "elasticsearch" }
        }
    ],
    "minimum_should_match" : 1,
    "boost" : 1.0
}

Grails プラグインの groovy API を使用して、次のように記述します。

def res = userAgentIdentService.search() {
    "bool" {
        "must" {
            term("user" : "kimchy" )
        }
        "must_not"  {
            "range"  {
                age("from" : 10, "to" : 20 }
            }
        }
        "should" : [
            {
                term( "tag" : "wow" )
            }
            {
                term("tag" : "elasticsearch" )
            }
        ]
        "minimum_should_match" = 1
        "boost" = 1.0
    } 

}

クエリが機能しません。

  1. どこで minimum_should_match を定義する必要があり、どのように定義する必要がありますか?

  2. "should" : [ ... ] 角括弧表記を grails/groovy の方法で記述するにはどうすればよいですか?

4

1 に答える 1