How can I configure my index to use BM25 in ElasticSearch using the JAVA API? -


i'm trying migrate mysql database elasticsearch can use full-text search technique using bm25 similarity on each fields. i'm using java fetch entries mysql , add them elasticsearch index.

i'm building index using java index api, can't figure out way set bm25 similarity on fields.

i consider table products table mysql , dev index products it's index type.

the original table products contains following fields :

  • id
  • title
  • description

you can find code on github, if you'd take look. it's forked project i've configured maven integration.

any suggestion , welcome, thanks!

i found answer question.

here code :

settings settings = immutablesettings             .settingsbuilder()             .put("cluster.name", "es_cluster_name"))             // define similarity module settings             .put("similarity.custom.type", "bm25")             .put("similarity.custom.k1", 2.0f)             .put("similarity.custom.b", 1.5f)             .build();  client client = new transportclient(settings); 

it seems can define similarity modules wish use in settings before instantiate client.

here list of similarity modules supported elasticsearch moment : default, bm25, dfr, ib, lmdirichlet , lmjelinekmercer. can specify 1 want use in settings below :

   .put("similarity.custom.type", "..." ) 

each similarity has own parameters want configure in order use properly.

note: code tested on elasticsearch 1.1.0.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -