ElasticSearch Indexing Key/Value Map

懵懂的女人 提交于 2019-12-08 07:33:28

问题


I'm using elasticsearch as indexing engine in my java project. I'm asking if there is anyway to index a java.util.Map a key/value Map.

For example i have this java class:

public class NextEvent extends NewtonResource{

  private Map<String, String> metadata;
  private Instant executionDate;
  private String type;
  protected Boolean executed;
  private List<PatchOperation> jsonPatch;
  private List<String> crons;
 ...
}

I want to create an elasticsearch mapping including the Map of metadata variable. somethings like this:

 {
    "aliases": {
        "posc-alias-nextevent": {}
    },
    "mappings": {
        "nextevent": {
            "properties": {
                "executed": {
                    "type": "boolean"
                },
                "executionDate": {
                    "type": "date"
                },
                "type": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "metadata": {
                    "type": "nested",
                    "properties": {
                        "key": {
                            "type": "string",
                            "index": "not_analyzed"
                        },
                        "value": {
                            "type": "string",
                            "index": "not_analyzed"
                        }
                    }
                }
            }
        }
    }
}

来源:https://stackoverflow.com/questions/48426474/elasticsearch-indexing-key-value-map

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!