【问题标题】:ElasticSearch Grails pluginElasticSearch Grails 插件
【发布时间】:2016-06-30 09:46:28
【问题描述】:

这是我第一次在我的Grails2.5.1application 中使用elasticsearch Grails plugin,当我尝试使用elasticSearchService.search("${age:35}").searchResults 或使用domainName.search("${age:35}").searchResults 搜索age=35 或使用domainName.search("${age:35}").searchResultssearchresults 是空的,尽管有一个数据库年龄中的记录等于35。是否有任何有用的教程将ElasticSearch 与 Grails 一起使用。

这是我的域名:

class EmploymentSeeker {
String empType
String email
String fullName
 String expYears
 String socialStatus
  Integer  nubOfKids =0
   String computerKnowledge
  String militaryStatus
  String haveDrivingLic
 String gender
 String eduQualification
 String hasVehicle
 String placeOfStudying
 String courses
 String currentTitle
 String currentEmployerName
 Integer age
 Date dateCreated


static searchable = {
age boost:2.0
root true
except = ['email', 'fullName', 'placeOfStudying', 'currentTitle', 'currentEmployerName', 'dateCreated']
}

 static constraints = {

}
static mapping={

}

}

【问题讨论】:

    标签: grails elasticsearch-plugin


    【解决方案1】:

    您的查询字符串中似乎有一个流氓“$”。应该是:

    elasticSearchService.search("age:35")

    ${..} 仅当您传入查询并希望 Groovy 在调用 ElasticSearchService 之前替换表达式时才需要。

    【讨论】:

    • 我按照你说的做了,但结果还是一样。
    • 那么没有太多信息很难说什么是错的。你确定数据被索引了吗?我个人没有使用过 Grails 插件——我们基于 Elasticsearch java api 推出了自己的客户端,主要是由于缺少您提到的文档。但是,您应该能够直接查询 elasticsearch 以查看对象是否被索引。 github.com/mobz/elasticsearch-head 在这方面会有所帮助。
    • 需要什么样的数据才能找出问题所在?
    猜你喜欢
    • 2016-06-28
    • 2014-11-08
    • 2023-03-06
    • 1970-01-01
    • 2014-08-02
    • 1970-01-01
    • 2014-12-18
    • 2018-04-14
    • 2016-09-25
    相关资源
    最近更新 更多