generator-jhipster: org.elasticsearch.search.SearchParseException: No mapping found for [id] in order to sort on
**Overview **
I’m not sure if i’m just overlooking something silly here, however i’m hitting this issue on my current project, and simulated in on a freshly generated jHipster application, and get the same result.
- Generate application using 4.5.3
- Select ‘search using elasticsearch’ option.
- Add a single entity ‘Book’ with name, description and price fields.
- Start up application, navigate to books entity page, then use search field:
2017-06-12 10:12:27.675 DEBUG 95115 --- [ XNIO-2 task-29] z.co.jmr.fake.aop.logging.LoggingAspect : Enter: za.co.jmr.fake.web.rest.BookResource.searchBooks() with argument[s] = [hello, Page request [number: 0, size 20, sort: _score: DESC,id: ASC]]
2017-06-12 10:12:27.675 DEBUG 95115 --- [ XNIO-2 task-29] za.co.jmr.fake.web.rest.BookResource : REST request to search for a page of Books for query hello
2017-06-12 10:12:27.676 DEBUG 95115 --- [ XNIO-2 task-29] z.co.jmr.fake.aop.logging.LoggingAspect : Enter: za.co.jmr.fake.service.BookService.search() with argument[s] = [hello, Page request [number: 0, size 20, sort: _score: DESC,id: ASC]]
2017-06-12 10:12:27.676 DEBUG 95115 --- [ XNIO-2 task-29] za.co.jmr.fake.service.BookService : Request to search for a page of Books for query hello
2017-06-12 10:12:27.745 ERROR 95115 --- [ XNIO-2 task-29] z.co.jmr.fake.aop.logging.LoggingAspect : Exception in za.co.jmr.fake.service.BookService.search() with cause = 'SearchParseException[No mapping found for [id] in order to sort on]' and exception = 'all shards failed'
org.elasticsearch.action.search.SearchPhaseExecutionException: all shards failed
at org.elasticsearch.action.search.AbstractSearchAsyncAction.onFirstPhaseResult(AbstractSearchAsyncAction.java:206)
at org.elasticsearch.action.search.AbstractSearchAsyncAction$1.onFailure(AbstractSearchAsyncAction.java:152)
at org.elasticsearch.action.ActionListenerResponseHandler.handleException(ActionListenerResponseHandler.java:46)
at org.elasticsearch.transport.TransportService$DirectResponseChannel.processException(TransportService.java:874)
at org.elasticsearch.transport.TransportService$DirectResponseChannel.sendResponse(TransportService.java:852)
at org.elasticsearch.transport.TransportService$4.onFailure(TransportService.java:389)
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:39)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.elasticsearch.search.SearchParseException: No mapping found for [id] in order to sort on
at org.elasticsearch.search.sort.SortParseElement.addSortField(SortParseElement.java:213)
at org.elasticsearch.search.sort.SortParseElement.addCompoundSortField(SortParseElement.java:187)
at org.elasticsearch.search.sort.SortParseElement.parse(SortParseElement.java:85)
at org.elasticsearch.search.SearchService.parseSource(SearchService.java:856)
at org.elasticsearch.search.SearchService.createContext(SearchService.java:667)
at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:633)
at org.elasticsearch.search.SearchService.executeDfsPhase(SearchService.java:264)
at org.elasticsearch.search.action.SearchServiceTransportAction$SearchDfsTransportHandler.messageReceived(SearchServiceTransportAction.java:360)
at org.elasticsearch.search.action.SearchServiceTransportAction$SearchDfsTransportHandler.messageReceived(SearchServiceTransportAction.java:357)
at org.elasticsearch.transport.TransportRequestHandler.messageReceived(TransportRequestHandler.java:33)
at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:77)
at org.elasticsearch.transport.TransportService$4.doRun(TransportService.java:378)
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
... 3 common frames omitted
JHipster configuration
{
"generator-jhipster": {
"promptValues": {
"packageName": "za.co.jmr.fake",
"nativeLanguage": "en"
},
"jhipsterVersion": "4.5.3",
"baseName": "fake",
"packageName": "za.co.jmr.fake",
"packageFolder": "za/co/jmr/fake",
"serverPort": "8080",
"authenticationType": "jwt",
"hibernateCache": "ehcache",
"clusteredHttpSession": false,
"websocket": "spring-websocket",
"databaseType": "sql",
"devDatabaseType": "h2Memory",
"prodDatabaseType": "mssql",
"searchEngine": "elasticsearch",
"messageBroker": false,
"serviceDiscoveryType": false,
"buildTool": "maven",
"enableSocialSignIn": false,
"jwtSecretKey": "2b3494fe754f94a922eb807326e97abefbd5c7e3",
"clientFramework": "angular1",
"useSass": true,
"clientPackageManager": "yarn",
"applicationType": "monolith",
"testFrameworks": [],
"jhiPrefix": "jhi",
"enableTranslation": true,
"nativeLanguage": "en",
"languages": [
"en"
]
}
}
Entity configuration(s) entityName.json files generated in the .jhipster directory
Book.json
{
"fluentMethods": true,
"relationships": [],
"fields": [
{
"fieldName": "name",
"fieldType": "String",
"fieldValidateRules": [
"required"
]
},
{
"fieldName": "description",
"fieldType": "String"
},
{
"fieldName": "price",
"fieldType": "BigDecimal",
"fieldValidateRules": [
"required",
"min",
"max"
],
"fieldValidateRulesMin": "100",
"fieldValidateRulesMax": "1000"
}
],
"changelogDate": "20170612081129",
"dto": "no",
"service": "serviceClass",
"entityTableName": "book",
"pagination": "pagination"
}
Browsers and Operating System
java version “1.8.0_65” Java™ SE Runtime Environment (build 1.8.0_65-b17) Java HotSpot™ 64-Bit Server VM (build 25.65-b01, mixed mode)
git version 2.11.0 (Apple Git-81)
node: v8.1.0
npm: 5.0.3
bower: 1.8.0
gulp: [10:24:30] CLI version 1.2.2 [10:24:30] Local version 3.9.1
yeoman: 1.8.5
yarn: 0.24.6
Docker version 17.06.0-ce-rc1, build 7f8486a
docker-compose version 1.13.0, build 1719ceb
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 15 (6 by maintainers)
It only happens the first time, when you have no data, so this entity is not indexed yet by Elasticsearch Maybe we can try to catch the error, but it should not happened when you have data
I don’t know why my new 5.1.0 project Elasticsearch still has errors even with data. I changed this.predicate = ‘_score’ to this.predicate = ‘id’,problem solved.So why generator use ‘_score’?