Grails中的ElasticSearch返回0个结果

时间:2018-10-09 13:18:50

标签: mysql elasticsearch grails groovy

我试图在Grails中运行elasticsearch serivce,但它返回0结果。

这是我的终端输出。如您所见,我总共找到5条记录,但是我的查询无法正常工作,并且字段也丢失了。

 es=[apps_read], indicesOptions=IndicesOptions[id=38, ignore_unavailable=false, allow_no_indices=true, expand_wildcards_open=true, expand_wildcards_closed=false, allow_alisases_to_multiple_indices=true, forbid_closed_indices=true], types=[user], routing='null', preference='null', requestCache=null, scroll=null, source={
      "from" : 0,
      "size" : 60,
      "query" : {
        "query_string" : {
          "query" : "user1",
          "fields" : [ ],
          "use_dis_max" : true,
          "tie_breaker" : 0.0,
          "default_operator" : "and",
          "auto_generate_phrase_queries" : false,
          "max_determinized_states" : 10000,
          "enable_position_increments" : true,
          "fuzziness" : "AUTO",
          "fuzzy_prefix_length" : 0,
          "fuzzy_max_expansions" : 50,
          "phrase_slop" : 0,
          "escape" : false,
          "split_on_whitespace" : true,
          "boost" : 1.0
        }
      },
      "min_score" : 0.0,
      "explain" : false
    }}
    2018-10-09 21:06:00.681 DEBUG --- [nio-8080-exec-5] g.p.elasticsearch.ElasticSearchService   : Completed search request.
    2018-10-09 21:06:00.714 DEBUG --- [nio-8080-exec-5] g.p.elasticsearch.ElasticSearchService   : {"took":13,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}
    2018-10-09 21:06:00.726 DEBUG --- [nio-8080-exec-5] g.p.elasticsearch.ElasticSearchService   : Search returned 0 result(s).

这就是我所谓的Elasticsearch服务

ElasticSearchService elasticSearchService
    def search() {
        elasticSearchService.search("user1", [indices: User, types: User, score: true]) as Map
    }

这是我的用户域

class User extends UserBase {

    long id
    UserTmp tmp

    //Creation information
    Date dateCreated
    Date lastUpdated

    static embedded = [ 'tmp' ]

    static mapping = {
        table "USER"
    }

    static searchable = true

    static constraints = {
        dateCreated()
        lastUpdated()
        createdBy(size: 1..50)
        updatedBy(size: 1..50)
        status()
    }
}

这是我的UserBase网域

abstract class UserBase implements Serializable, Comparable<UserBase> {

    //User information
    String username
    String password
    String firstName
    String lastName
    String email
    String phoneNumber
    String address

    static constraints = {
        username(size: 1..20)
        password(size: 1..20)
        firstName(size: 1..50)
        lastName(nullable: true, size: 1..50)
        email(size: 1..50)
        phoneNumber(size: 1..20)
        address(size: 1..150)
    }

    static searchable = true

    @Override
    public int compareTo(UserBase other) {
        return this.id <=> other.id
    }
}

0 个答案:

没有答案