2014-12-17 4 views
1

의 내가 간단한 ElasticSearch 지수하게 가정 해 봅시다 :ElasticSearch - 동일한 필드 이름을 가진 다른 doc_types하지만 서로 다른 분석기를 검색

curl -XPUT 'http://localhost:9200/test/' -d '{ 
    "settings": { 
     "analysis": { 
      "char_filter": { 
       "de_acronym": { 
        "type": "mapping", 
        "mappings": [".=>"] 
       } 
      }, 
      "analyzer": { 
       "analyzer1": { 
        "type":  "custom", 
        "tokenizer": "keyword", 
        "char_filter": ["de_acronym"] 
       } 
      } 
     } 
    } 
}' 

을 내가 동일한 속성 name이 두 doc_types을하지만 다르게 약간 분석 서로 :

다음,의 내가 같은 이름을 가진 각 DOC_TYPE에서 문서를 넣어 가정 해 봅시다
curl -XPUT 'http://localhost:9200/test/_mapping/docA' -d '{ 
    "docA": { 
     "properties": { 
      "name": { 
       "type": "string", 
       "analyzer": "simple" 
      } 
     } 
    } 
}' 
curl -XPUT 'http://localhost:9200/test/_mapping/docB' -d '{ 
    "docB": { 
     "properties": { 
      "name": { 
       "type": "string", 
       "analyzer": "analyzer1" 
      } 
     } 
    } 
}' 

:

curl -XPUT 'http://localhost:9200/test/docA/1' -d '{ "name" : "U.S. Army" }' 
curl -XPUT 'http://localhost:9200/test/docB/1' -d '{ "name" : "U.S. Army" }' 

'미국'을 검색해 봅시다. !

curl -XGET 'http://localhost:9200/test/_search?pretty' -d '{ 
    "query": { 
     "match_phrase": { 
      "name": { 
       "query": "U.S. Army" 
      } 
     } 
    } 
}' 
{ 
    "took" : 2, 
    "timed_out" : false, 
    "_shards" : { 
    "total" : 5, 
    "successful" : 5, 
    "failed" : 0 
    }, 
    "hits" : { 
    "total" : 1, 
    "max_score" : 1.5, 
    "hits" : [ { 
     "_index" : "test", 
     "_type" : "docA", 
     "_id" : "1", 
     "_score" : 1.5, 
     "_source":{ "name" : "U.S. Army" } 
    } ] 
    } 
} 
내가 하나 개의 결과를 얻을 수

은 내가 docB의 분석기 지정 다른 결과를 얻을 : 동시에 두 문서 유형의 육군 "

curl -XGET 'http://localhost:9200/test/_search?pretty' -d ' 
{ 
    "query": { 
     "match_phrase": { 
      "name": { 
       "query": "U.S. Army", 
       "analyzer": "analyzer1" 
      } 
     } 
    } 
}' 
{ 
    "took" : 2, 
    "timed_out" : false, 
    "_shards" : { 
    "total" : 5, 
    "successful" : 5, 
    "failed" : 0 
    }, 
    "hits" : { 
    "total" : 1, 
    "max_score" : 1.0, 
    "hits" : [ { 
     "_index" : "test", 
     "_type" : "docB", 
     "_id" : "1", 
     "_score" : 1.0, 
     "_source":{ "name" : "U.S. Army" } 
    } ] 
    } 
} 

내가 인상했다가 그 ES는 것 적절한 분석기로 각 DOC_TYPE를 검색 할 수있는 방법이 있나요

ElasticSearch 워드 프로세서

precedence for search analyzer가가는 말 :.?

1) 분석기 이 경우

2) 다른 필드 매핑에 정의 된 분석기 ...

다른 쿼리 자체에 정의 된, ElasticSearch 임의로 사용할 필드 매핑 선택인가?

답변

2

github에서 this 문제를 봅니다.이 게시물은 Google 그룹스의 this 게시물에서 시작한 것 같습니다. 나는 귀하의 질문에 답변을 믿는다는 필터링 된 쿼리에, 우리는 그것을 추측 할 수없는 경우

, 그래서 우리는 단순히 그 중 하나를 선택하고 분석 설정 사용을

관련 문제