- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我想使用 mongodb、grails 和 elasticsearch 进行简单的搜索。但是我发现了这个问题,无法理解如何实现解决方案。
这是我的域类
package hellokitty
class Person {
String name
static mapWith = "mongo"
static searchable = {
only = 'name'
}
static constraints = {
}
}
这是我的build.gradle文件
buildscript {
ext {
grailsVersion = '3.3.2'
gormVersion = '6.1.8.RELEASE'
elasticsearchVersion = '5.4.1'
elasticsearchAttachmentsVersion = '5.4.1'
}
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
classpath "gradle.plugin.com.energizedwork.webdriver-binaries:webdriver-binaries-gradle-plugin:1.1"
classpath "gradle.plugin.com.energizedwork:idea-gradle-plugins:1.4"
//classpath "org.grails.plugins:hibernate5:${gormVersion-".RELEASE"}"
classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.14.6"
}
}
version "0.1"
group "hellokitty"
apply plugin:"eclipse"
apply plugin:"idea"
apply plugin:"war"
apply plugin:"org.grails.grails-web"
apply plugin:"com.energizedwork.webdriver-binaries"
apply plugin:"com.energizedwork.idea-project-components"
apply plugin:"asset-pipeline"
apply plugin:"org.grails.grails-gsp"
ext {
gradleWrapperVersion = '3.5'
elasticsearchVersion = '5.4.1'
elasticsearchAttachmentsVersion = '5.4.1'
}
ext['elasticsearch.version'] = '5.4.1'
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencyManagement {
imports {
mavenBom "org.grails:grails-bom:$grailsVersion"
}
applyMavenExclusions false
}
dependencies {
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.grails:grails-core"
compile "org.springframework.boot:spring-boot-starter-actuator"
//compile "org.springframework.boot:spring-boot-starter-tomcat"
provided "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-web-boot"
compile "org.grails:grails-logging"
compile "org.grails:grails-plugin-rest"
compile "org.grails:grails-plugin-databinding"
compile "org.grails:grails-plugin-i18n"
compile "org.grails:grails-plugin-services"
compile "org.grails:grails-plugin-url-mappings"
compile "org.grails:grails-plugin-interceptors"
compile "org.grails.plugins:cache"
compile "org.grails.plugins:async"
compile "org.grails.plugins:scaffolding"
compile "org.grails.plugins:events"
//compile "org.grails.plugins:hibernate5"
// compile "org.hibernate:hibernate-core:5.1.5.Final"
compile 'org.grails.plugins:spring-security-core:3.2.0'
compile "org.grails.plugins:gsp"
//compile "org.grails.plugins:elasticsearch:2.4.0"
compile "org.grails.plugins:mongodb"
// compile 'org.grails.plugins:mongodb:6.1.4'
compile("org.grails:gorm-mongodb-spring-boot:6.1.2.RELEASE")
compile 'org.grails.plugins:elasticsearch:2.4.0.RC1'
//compile 'org.elasticsearch:elasticsearch:5.4.1'
console "org.grails:grails-console"
profile "org.grails.profiles:web"
// compile 'org.grails.plugins:elasticsearch:2.4.0.RC1'
runtime 'org.elasticsearch.plugin:mapper-attachments:2.4.6'
runtime "org.glassfish.web:el-impl:2.1.2-b03"
//runtime "com.h2database:h2"
runtime "org.apache.tomcat:tomcat-jdbc"
runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.14.6"
testCompile "org.grails:grails-gorm-testing-support"
testCompile "org.grails:grails-web-testing-support"
testCompile "org.grails.plugins:geb"
testRuntime "org.seleniumhq.selenium:selenium-chrome-driver:3.6.0"
testRuntime "org.seleniumhq.selenium:selenium-firefox-driver:3.6.0"
testRuntime "org.seleniumhq.selenium:selenium-remote-driver:3.6.0"
testRuntime "org.seleniumhq.selenium:selenium-api:3.6.0"
}
bootRun {
jvmArgs('-Dspring.output.ansi.enabled=always')
addResources = true
}
webdriverBinaries {
chromedriver '2.32'
geckodriver '0.18.0'
}
tasks.withType(Test) {
systemProperty "geb.env", System.getProperty('geb.env')
systemProperty "webdriver.chrome.driver", System.getProperty('webdriver.chrome.driver')
systemProperty "webdriver.gecko.driver", System.getProperty('webdriver.gecko.driver')
}
assets {
minifyJs = true
minifyCss = true
}
这是我的application.yml文件
---
grails:
profile: web
codegen:
defaultPackage: hellokitty
spring:
transactionManagement:
proxies: false
gorm:
reactor:
# Whether to translate GORM events into Reactor events
# Disabled by default for performance reasons
events: false
info:
app:
name: '@info.app.name@'
version: '@info.app.version@'
grailsVersion: '@info.app.grailsVersion@'
spring:
main:
banner-mode: "off"
groovy:
template:
check-template-location: false
# Spring Actuator Endpoints are Disabled by Default
endpoints:
enabled: false
jmx:
enabled: true
---
grails:
mime:
disable:
accept:
header:
userAgents:
- Gecko
- WebKit
- Presto
- Trident
types:
all: '*/*'
atom: application/atom+xml
css: text/css
csv: text/csv
form: application/x-www-form-urlencoded
html:
- text/html
- application/xhtml+xml
js: text/javascript
json:
- application/json
- text/json
multipartForm: multipart/form-data
pdf: application/pdf
rss: application/rss+xml
text: text/plain
hal:
- application/hal+json
- application/hal+xml
xml:
- text/xml
- application/xml
urlmapping:
cache:
maxsize: 1000
controllers:
defaultScope: singleton
converters:
encoding: UTF-8
views:
default:
codec: html
gsp:
encoding: UTF-8
htmlcodec: xml
codecs:
expression: html
scriptlets: html
taglib: none
staticparts: none
endpoints:
jmx:
unique-names: true
---
#hibernate:
# cache:
# queries: false
# use_second_level_cache: false
# use_query_cache: false
#dataSource:
# pooled: true
# jmxExport: true
# driverClassName: org.h2.Driver
# username: sa
# password: ''
elasticSearch:
date:
formats: ["yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"]
client.hosts:
- {host: localhost, port: 9300}
datastoreImpl: mongoDatastore
defaultExcludedProperties: ['password']
disableAutoIndex: false
index:
compound_format: true
unmarshallComponents: true
searchableProperty:
name: searchable
includeTransients: false
environments:
development:
grails:
serverURL: http://localhost:8080
mongodb:
host: "localhost"
port: 27017
username: ""
password: ""
databaseName: "people"
elasticSearch:
client:
mode: local
transport.sniff: true
bulkIndexOnStartup: true
datastoreImpl: mongoDatastore
production:
grails:
mongodb:
host: "localhost"
port: 27017
username: ""
password: ""
databaseName: "people"
elasticSearch:
client:
mode: node
但是我得到了这个错误。我无法理解如何实现它建议的ACTION
/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home/bin/java ...
| Running application...
Configuring Spring Security Core ...
... finished configuring Spring Security Core
2018-02-07 19:30:54.622 ERROR --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Field mappingContext in grails.plugins.elasticsearch.mapping.DomainReflectionService required a single bean, but 2 were found:
- grailsDomainClassMappingContext: defined in null
- mongoMappingContext: defined by method 'getMappingContext' in null
Action:
Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':bootRun'.
> Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
| Error Failed to start server (Use --stacktrace to see the full trace)
Process finished with exit code 1
任何人都可以给我任何建议吗??谢谢
最佳答案
其实我也遇到了同样的问题,所以我创建了一个 issue 并由 grails 团队修复。
https://github.com/puneetbehl/elasticsearch-grails-plugin/issues/26
因此,只需将您的 elasticsearch 版本更新为 2.4.2 或替换为以下依赖项即可。
编译“org.grails.plugins:elasticsearch:2.4.2”。
感谢 Puneet Behl 修复并将此修复程序引入 2.4.2 版本。
关于mongodb - 如何在 grails 和 elasticsearch 中定义单个 bean,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48665626/
我在这里有一个问题,我不知道这是否正常。 但是我认为这里有些湖,安装插件elasticsearch-head之后,我在浏览器中启动url“http://localhost:9200/_plugin/h
我写了这个 flex 搜索查询: es.search(index=['ind1'],doc_type=['doc']) 我得到以下结果: {'_shards': {'failed': 0, 'skip
在ElasticSearch.Net v.5中,存在一个属性 Elasticsearch.Net.RequestData.Path ,该属性在ElasticSearch.Net v.6中已成为depr
如何让 elasticsearch 应用新配置?我更改了文件 ~ES_HOME/config/elasticsearch.yml 中的一个字符串: # Disable HTTP completely:
我正在尝试使用以下分析器在 elastic serach 7.1 中实现部分子字符串搜索 PUT my_index-001 { "settings": { "analysis": {
假设一个 elasticsearch 服务器在很短的时间内接收到 100 个任务。有些任务很短,有些任务很耗时,有些任务是删除任务,有些是插入和搜索查询。 elasticsearch 是如何决定先运行
我需要根据日期过滤一组值(在此处添加字段),然后按 device_id 对其进行分组。所以我正在使用以下东西: { "aggs":{ "dates_between":{ "fi
我在 Elasticsearch 中有一个企业索引。索引中的每个文档代表一个业务,每个业务都有business_hours。我试图允许使用星期几和时间过滤营业时间。例如,我们希望能够进行过滤,以显示我
我有一个这样的过滤查询 query: { filtered: { query: { bool: { should: [{multi_match: {
Elasticsearch 相当新,所以可能不得不忍受我,我遇到了一个问题,如果我使用 20 个字符或更少的字符搜索文档,文档会出现,但是查询中同一个单词中的任何更多字符,我没有结果: 使用“苯氧甲基
我试图更好地理解 ElasticSearch 的内部结构,所以我想知道 ElasticSearch 在内部计算以下两种情况的术语统计信息的方式是否存在任何差异。 第一种情况是当我有这样的文件时: {
在我的 elasticsearch 索引中,我索引了一堆工作。为简单起见,我们只说它们是一堆职位。当人们在我的搜索引擎中输入职位时,我想“自动完成”可能的匹配。 我在这里调查了完成建议:http://
我在很多映射中使用多字段。在 Elastic Search 的文档中,指示应将多字段替换为“fields”参数。参见 http://www.elasticsearch.org/guide/en/ela
我有如下查询, query = { "query": {"query_string": {"query": "%s" % q}}, "filter":{"ids
我有一个Json数据 "hits": [ { "_index": "outboxprov1", "_type": "deleted-c
这可能是一个初学者的问题,但我对大小有一些疑问。 根据 Elasticsearch 规范,大小的最大值可以是 10000,我想在下面验证我的理解: 示例查询: GET testindex-2016.0
我在 Elastic Search 中发现了滚动功能,这看起来非常有趣。看了那么多文档,下面的问题我还是不清楚。 如果偏移量已经存在那么为什么要使用滚动? 即将到来的记录呢?假设它完成了所有数据的滚动
我有以下基于注释的 Elasticsearch 配置,我已将索引设置为不被分析,因为我不希望这些字段被标记化: @Document(indexName = "abc", type = "efg
我正在尝试在单个索引中创建多个类型。例如,我试图在host索引中创建两种类型(post,ytb),以便在它们之间创建父子关系。 PUT /ytb { "mappings": { "po
我尝试创建一个简单的模板,包括一些动态模板,但我似乎无法为文档编制索引。 我得到错误: 400 {"error":"MapperParsingException[mapping [_default_]
我是一名优秀的程序员,十分优秀!