ElasticSearch completion suggester formatting with Java client -


i new suggester java api elasticsearch, using version 2.1.1, resources on net curl instead of java example, got index called "facebook" , 1 dataset prepared. can searched search api

completionsuggestionbuilder suggestionsbuilder = new completionsuggestionbuilder("completeme");         suggestionsbuilder.text("qui");         suggestionsbuilder.field("content");         suggestrequestbuilder suggestrequestbuilder =                 client.preparesuggest("facebook").addsuggestion(suggestionsbuilder); 

then try on suggester api of elasticsearch, got these errors dont know missing out. please advice me examples. in advance.

{author=lance tan kah woon, postdate=2016-01-31t13:16:49.767z, title=posting, content=today's weather quite ok, tags=[hashtag]} ------------------------------------------------------- 16947 [elasticsearch[ego living planet][suggest][t#1]] debug org.elasticsearch.action.suggest  - [ego living planet] [facebook][0], node[degugndosjiepr9gmltemg], [p], v[36], s[started], a[id=erze_ktisnu5xjh83j4aqw]: failed execute [[[facebook]], suggestsource[{"completeme":{"text":"qui","completion":{"field":"content"}}}]] remotetransportexception[[ego living planet][127.0.0.1:9300][indices:data/read/suggest[s]]]; nested: elasticsearchexception[failed execute suggest]; nested: classcastexception[org.elasticsearch.index.mapper.core.stringfieldmapper$stringfieldtype cannot cast org.elasticsearch.index.mapper.core.completionfieldmapper$completionfieldtype]; caused by: elasticsearchexception[failed execute suggest]; nested: classcastexception[org.elasticsearch.index.mapper.core.stringfieldmapper$stringfieldtype cannot cast org.elasticsearch.index.mapper.core.completionfieldmapper$completionfieldtype];     @ org.elasticsearch.action.suggest.transportsuggestaction.shardoperation(transportsuggestaction.java:152)     @ org.elasticsearch.action.suggest.transportsuggestaction.shardoperation(transportsuggestaction.java:61)     @ org.elasticsearch.action.support.broadcast.transportbroadcastaction$shardtransporthandler.messagereceived(transportbroadcastaction.java:268)     @ org.elasticsearch.action.support.broadcast.transportbroadcastaction$shardtransporthandler.messagereceived(transportbroadcastaction.java:264)     @ org.elasticsearch.transport.transportservice$4.dorun(transportservice.java:350)     @ org.elasticsearch.common.util.concurrent.abstractrunnable.run(abstractrunnable.java:37)     @ java.util.concurrent.threadpoolexecutor.runworker(unknown source)     @ java.util.concurrent.threadpoolexecutor$worker.run(unknown source)     @ java.lang.thread.run(unknown source) caused by: java.lang.classcastexception: org.elasticsearch.index.mapper.core.stringfieldmapper$stringfieldtype cannot cast org.elasticsearch.index.mapper.core.completionfieldmapper$completionfieldtype     @ org.elasticsearch.search.suggest.completion.completionsuggestparser.parse(completionsuggestparser.java:105)     @ org.elasticsearch.search.suggest.suggestparseelement.parseinternal(suggestparseelement.java:94)     @ org.elasticsearch.action.suggest.transportsuggestaction.shardoperation(transportsuggestaction.java:145)     ... 8 more 16948 [elasticsearch[ego living planet][suggest][t#3]] debug org.elasticsearch.action.suggest  - [ego living planet] [facebook][2], node[degugndosjiepr9gmltemg], [p], v[36], s[started], a[id=zh03jw9srb6rhdyuxvrw6g]: failed execute [[[facebook]], suggestsource[{"completeme":{"text":"qui","completion":{"field":"content"}}}]] remotetransportexception[[ego living planet][127.0.0.1:9300][indices:data/read/suggest[s]]]; nested: elasticsearchexception[failed execute suggest]; nested: classcastexception[org.elasticsearch.index.mapper.core.stringfieldmapper$stringfieldtype cannot cast org.elasticsearch.index.mapper.core.completionfieldmapper$completionfieldtype]; caused by: elasticsearchexception[failed execute suggest]; nested: classcastexception[org.elasticsearch.index.mapper.core.stringfieldmapper$stringfieldtype cannot cast org.elasticsearch.index.mapper.core.completionfieldmapper$completionfieldtype];     @ org.elasticsearch.action.suggest.transportsuggestaction.shardoperation(transportsuggestaction.java:152)     @ org.elasticsearch.action.suggest.transportsuggestaction.shardoperation(transportsuggestaction.java:61)     @ org.elasticsearch.action.support.broadcast.transportbroadcastaction$shardtransporthandler.messagereceived(transportbroadcastaction.java:268)     @ org.elasticsearch.action.support.broadcast.transportbroadcastaction$shardtransporthandler.messagereceived(transportbroadcastaction.java:264)     @ org.elasticsearch.transport.transportservice$4.dorun(transportservice.java:350)     @ org.elasticsearch.common.util.concurrent.abstractrunnable.run(abstractrunnable.java:37)     @ java.util.concurrent.threadpoolexecutor.runworker(unknown source)     @ java.util.concurrent.threadpoolexecutor$worker.run(unknown source)     @ java.lang.thread.run(unknown source) caused by: java.lang.classcastexception: org.elasticsearch.index.mapper.core.stringfieldmapper$stringfieldtype cannot cast org.elasticsearch.index.mapper.core.completionfieldmapper$completionfieldtype     @ org.elasticsearch.search.suggest.completion.completionsuggestparser.parse(completionsuggestparser.java:105)     @ org.elasticsearch.search.suggest.suggestparseelement.parseinternal(suggestparseelement.java:94)     @ org.elasticsearch.action.suggest.transportsuggestaction.shardoperation(transportsuggestaction.java:145)     ... 8 more 

as error suggests, es not able map field content completion field type. need change mapping this.

put facebook {   "mappings": {     "my_type": {       "properties": {         "content": {           "type": "completion"         }       }     }   } } 

you can refer docs more info. need reindex data , suggestions work.

edit 1 : java api, can first create index facebook , apply mapping this. can refer this question.

client.admin().indices().create(new createindexrequest("facebook")).actionget();   xcontentbuilder mapping = jsonbuilder()                               .startobject()                                    .startobject("doctype")                                         .startobject("properties")                                             .startobject("content")                                                 .field("type", "completion")                                              .endobject()                                         .endobject()                                     .endobject()                                  .endobject();    putmappingresponse putmappingresponse = client.admin().indices()                 .prepareputmapping("facebook")                 .settype("doctype")                 .setsource(mapping)                 .execute().actionget(); 

please refer official docs while getting started.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -