2017-09-26 2 views
0

공백을 무시하는 분석기가 있습니다. 공백없이 문자열을 검색하면 적절한 결과가 반환됩니다.쿼리의 공백 문자

{ 
    "index": { 
    "number_of_shards": 1, 
    "analysis": { 
     "filter": { 
     "word_joiner": { 
      "type": "word_delimiter", 
      "catenate_all": true 
     } 
     }, 
     "analyzer": { 
     "word_join_analyzer": { 
      "type": "custom", 
      "filter": [ 
      "word_joiner" 
      ], 
      "tokenizer": "keyword" 
     } 
     } 
    } 
    } 
} 

이 작동 방법은 다음과 같습니다 :이 분석기입니다

curl -XGET "http://localhost:9200/cake/_analyze?analyzer=word_join_analyzer&pretty" -d 'ONE"\ "TWO' 

결과 :

{ 
    "tokens" : [ { 
    "token" : "ONE", 
    "start_offset" : 1, 
    "end_offset" : 5, 
    "type" : "word", 
    "position" : 0 
    }, { 
    "token" : "ONETWO", 
    "start_offset" : 1, 
    "end_offset" : 13, 
    "type" : "word", 
    "position" : 0 
    }, { 
    "token" : "TWO", 
    "start_offset" : 7, 
    "end_offset" : 13, 
    "type" : "word", 
    "position" : 1 
    } ] 
} 

는 내가 원하는 것은 내가이 분석에서 "token" : "ONE TWO"를 얻을 수 있다는 것입니다. 어떻게해야합니까?
감사합니다.

답변

2

당신은

{ 
    "index": { 
    "number_of_shards": 1, 
    "analysis": { 
     "filter": { 
     "word_joiner": { 
      "type": "word_delimiter", 
      "catenate_all": true, 
      "preserve_original": true   <--- add this 
     } 
     }, 
     "analyzer": { 
     "word_join_analyzer": { 
      "type": "custom", 
      "filter": [ 
      "word_joiner" 
      ], 
      "tokenizer": "keyword" 
     } 
     } 
    } 
    } 
} 

이 얻을 것 기본적으로 거짓 인 preserve_original 설정을 활성화해야합니다

{ 
    "tokens": [ 
    { 
     "token": "ONE TWO", 
     "start_offset": 0, 
     "end_offset": 7, 
     "type": "word", 
     "position": 0 
    }, 
    { 
     "token": "ONE", 
     "start_offset": 0, 
     "end_offset": 3, 
     "type": "word", 
     "position": 0 
    }, 
    { 
     "token": "ONETWO", 
     "start_offset": 0, 
     "end_offset": 7, 
     "type": "word", 
     "position": 0 
    }, 
    { 
     "token": "TWO", 
     "start_offset": 4, 
     "end_offset": 7, 
     "type": "word", 
     "position": 1 
    } 
    ] 
} 
+1

을 당신은 나의 영웅 :)입니다 – Anna

+0

신난다, 다행이 도움이 ;-) – Val