You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@nutch.apache.org by "MrSrivastavaRK ." <sr...@gmail.com> on 2016/09/09 22:20:16 UTC

How to pass "type" in elasticindexwriter.java

Hi All,

I am indexing urls in ES and want to pass url type for each url e.g.
http://www.indianfoodurl.com then type will be "indianfood" and
http://www.chinesefoodurl.com then type will be "chinesefood" not "doc" as
its taking default for all te url in below code

public void write(NutchDocument doc) throws IOException {
    String id = (String) doc.getFieldValue("id");
   * String type = doc.getDocumentMeta().get("type");*
    if (type == null)
      type = "doc";
    IndexRequestBuilder request = client.prepareIndex(defaultIndex, type, id);

In nutch-site.xml , elastic index name is "foodindex" so i can search
indianfood , chinesefood separately.

Please suggest any OOB the way to achieve this. I ma trying NUtch Rest API
for crawling.
-- 
Regards
Raj