I have created index and some data in map and assigned that a type by using elasticsearch-grails-plugin
https://grails.org/plugin/elasticsearch, via low level api, but when I try to perform a search using elasticSearchService.search()
and specify by package/type in params, I get an exception that the object type doesnt is unknown:
java.lang.IllegalArgumentException: Unknown object type: mypackagetype1
at org.grails.plugins.elasticsearch.ElasticSearchService$$EPFkEyq8.resolveIndicesAndTypes(ElasticSearchService.groovy:545)
at org.grails.plugins.elasticsearch.ElasticSearchService$$EPFkEyq8.search(ElasticSearchService.groovy:438)
at org.grails.plugins.elasticsearch.ElasticSearchService$$EPFkEyq8.search(ElasticSearchService.groovy:64)
Here is how I have added index and data to package.
def somemypackagetype1data = [name:'Alan', city:'Newyork']
elasticSearchHelper.withElasticSearch { Client client ->
def response = client.prepareIndex("myindex", "mypackagetype1")
.setSource(somemypackagetype1data)
.execute()
.actionGet()
}
and here is how the search is performed, which throws the above excpetion:
elasticSearchService.search([types:'mypackagetype1'],
{
query_string(fields: ["name"],
query: searchQuery)
}, null)
But when I try to get the mappings by elasticSearchContextHolder.mapping
it doesn't return anything. and interestingly when i do check if the mapping exists using elasticSearchAdminService
, it returns as positive.
elasticSearchAdminService.mappingExists("myindex", "mypackagetype1")
Why am I getting the object type unknown exception? Though i have already added it...
As @cfrick commented, Only Domain mapping is supported currently. So I have handled it via low level api call