ElasticSearch1.7.3 Root type mapping not empty after parsing 오류 보고!

3698 단어
루틴에 익숙해진 지도 오래됐고, 최근 엘라스틱서치의 원리와 간단한 사용에 대해 알아보고 싶다.
코드는 다음과 같습니다.
 try
        {
            XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("xivaik").startObject("properties").startObject("ajmc").field("type", "string")
                    .field("store", "yes").endObject().startObject("ajbh").field("type", "string").field("store", "yes").field("index", "not_analyzed").endObject()
                    .startObject("jyaq").field("type", "string").field("indexAnalyzer", "ik").field("searchAnalyzer", "ik").field("index", "analyzed").endObject()
                    .startObject("addDate").field("type", "date").endObject().endObject().endObject().endObject();

            PutMappingRequest mappingRequest = Requests.putMappingRequest("xivaik").type("infoaj").source(mapping);

            client.admin().indices().putMapping(mappingRequest).actionGet();

        }
        catch (IOException e)
        {
            e.printStackTrace();
        }

 
실행 중 Root type mapping not empty after parsing 오류가 발생했습니다!
나중에 이 게시물을 보고 나에게 약간의 깨우침을 주었다.
I removed the "mappings" json object and it fixed the issue.

 
http://stackoverflow.com/questions/29304374/elasticsearch-java-root-type-mapping-not-empty-after-parsing
마핑 리퀘스트를 구축하고 있는 것 같습니다. 노드 중복 구조가 생겼습니다.
내가 구성하고자 했던 정보는 다음과 같다.
{"xivaik":{"properties":{"ajmc":{"type":"string","store":"yes"},"ajbh":{"type":"string","store":"yes","index":"not_analyzed"},"jyaq":{"type":"string","indexAnalyzer":"ik","searchAnalyzer":"ik","index":"analyzed"},"addDate":{"type":"date"}}}}
startObject("xivaik")가 내 색인xivaik를 구조 정보에 추가했지만 Requests.putMappingRequest("xivaik").type ("infoaj") 에서 색인xivaik를 지정했는데, 중복된 것 같지 않습니다.
없애다putMappingRequest("xivaik")는 불가능하기 때문에 구조를 구축하는 문장에서 startObject("xivaik")를 제거한 결과 성공적으로 실행되었습니다.
try
        {
            XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("properties").startObject("ajmc").field("type", "string")
                    .field("store", "yes").endObject().startObject("ajbh").field("type", "string").field("store", "yes").field("index", "not_analyzed").endObject()
                    .startObject("jyaq").field("type", "string").field("indexAnalyzer", "ik").field("searchAnalyzer", "ik").field("index", "analyzed").endObject()
                    .startObject("addDate").field("type", "date").endObject().endObject().endObject();

            PutMappingRequest mappingRequest = Requests.putMappingRequest("xivaik").type("infoaj").source(mapping);

            client.admin().indices().putMapping(mappingRequest).actionGet();

        }
        catch (IOException e)
        {
            e.printStackTrace();
        }

 
결과는 앞의 추측을 증명했다.나중에 참고해 주셨으면 좋겠습니다.

좋은 웹페이지 즐겨찾기