0

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...

sufyan.shoaib
  • 1,117
  • 9
  • 19
  • 1
    the service can only handle his own mappings https://github.com/noamt/elasticsearch-grails-plugin/blob/master/grails-app/services/org/grails/plugins/elasticsearch/ElasticSearchService.groovy#L537-L545 – cfrick Jun 16 '15 at 06:08
  • @cfrick so seems like I can only reference a Domain mapping for now, Its not supporting json and map (which i have added). – sufyan.shoaib Jun 16 '15 at 06:14

1 Answers1

0

As @cfrick commented, Only Domain mapping is supported currently. So I have handled it via low level api call

sufyan.shoaib
  • 1,117
  • 9
  • 19