2016-08-03 2 views
1

아포스트로피가있는 단어로 구성된 문장을 찾으려고합니다. 그래서, 본문탄성이 아포스트로피 (')로 단어를 찾지 못합니다.

외국인에게 전형적인 영어 요리를 부탁하면 은 아마 피쉬 앤 칩스를 말하고 멈출 것입니다. 그것은 실망 스럽지만, 사실이지만, 우리 음식은 그러한 준비에 도움이되지 않기 때문에 레스토랑에서 먹는 영국에는 전통이 없다는 것은 사실입니다. 영국 요리는 집에서 찾을 수 있습니다. 요리를 완벽하게 시간을 정할 수 있습니다. 그래서 합리적인 가격

내가 식당에서 먹는 영국에는 전통이 없다는 것을,

가 실망하지만, 사실 것을 발견하려고

와 좋은 영어 레스토랑을 찾기 어렵습니다 우리의 음식이

을하지 않기 때문에, 나는 쿼리를 만들

{ 
"_index": "liza_index", 
"_type": ".percolator", 
"_id": "1594", 
"_version": 37, 
"found": true, 
"_source": { 
    "query": { 
     "bool": { 
      "minimum_should_match": 1, 
      "should": { 
       "span_or": { 
        "clauses": [{ 
         "span_near": { 
          "in_order": true, 
          "clauses": [{ 
           "span_multi": { 
            "match": { 
             "regexp": { 
              "message": "it" 
             } 
            } 
           } 
          }, { 
           "span_multi": { 
            "match": { 
             "regexp": { 
              "message": "is" 
             } 
            } 
           } 
          }, { 
           "span_multi": { 
            "match": { 
             "regexp": { 
              "message": "disappointing" 
             } 
            } 
           } 
          }, { 
           "span_multi": { 
            "match": { 
             "regexp": { 
              "message": "but" 
             } 
            } 
           } 
          }, { 
           "span_multi": { 
            "match": { 
             "regexp": { 
              "message": "true" 
             } 
            } 
           } 
          }, { 
           "span_multi": { 
            "match": { 
             "regexp": { 
              "message": "that" 
             } 
            } 
           } 
          }, { 
           "span_multi": { 
            "match": { 
             "regexp": { 
              "message": "there" 
             } 
            } 
           } 
          }, { 
           "span_multi": { 
            "match": { 
             "regexp": { 
              "message": "is" 
             } 
            } 
           } 
          }, { 
           "span_multi": { 
            "match": { 
             "regexp": { 
              "message": "no" 
             } 
            } 
           } 
          }, { 
           "span_multi": { 
            "match": { 
             "regexp": { 
              "message": "tradition" 
             } 
            } 
           } 
          }, { 
           "span_multi": { 
            "match": { 
             "regexp": { 
              "message": "in" 
             } 
            } 
           } 
          }, { 
           "span_multi": { 
            "match": { 
             "regexp": { 
              "message": "britain" 
             } 
            } 
           } 
          }, { 
           "span_multi": { 
            "match": { 
             "regexp": { 
              "message": "of" 
             } 
            } 
           } 
          }, { 
           "span_multi": { 
            "match": { 
             "regexp": { 
              "message": "eating" 
             } 
            } 
           } 
          }, { 
           "span_multi": { 
            "match": { 
             "regexp": { 
              "message": "in" 
             } 
            } 
           } 
          }, { 
           "span_multi": { 
            "match": { 
             "regexp": { 
              "message": "restaurants" 
             } 
            } 
           } 
          }, { 
           "span_multi": { 
            "match": { 
             "regexp": { 
              "message": "because" 
             } 
            } 
           } 
          }, { 
           "span_multi": { 
            "match": { 
             "regexp": { 
              "message": "our" 
             } 
            } 
           } 
          }, { 
           "span_multi": { 
            "match": { 
             "regexp": { 
              "message": "food" 
             } 
            } 
           } 
          }, { 
           "span_multi": { 
            "match": { 
             "regexp": { 
              "message": "doesn't" 
             } 
            } 
           } 
          }], 
          "slop": 0, 
          "collect_payloads": false 
         } 
        }] 
       } 
      } 
     } 
    } 
}} 

하지만 신축성이 발견되지 않습니다. "않는"쿼리가 작동합니다.

아포스트로피 앞에 백 슬래시를 추가하려고했습니다. "doesn \ t"은 유효하지 않으므로 "doesn \\ 't"및 "doesn \\\\'t"를 만들었습니다. 그러나 그것은 효과가 없습니다.

가 그렇고, 나는 하나 개의 단어로 쿼리를 만들 너무 작동하지 않습니다 백 슬래시 및

{ 
"_index": "liza_index", 
"_type": ".percolator", 
"_id": "2101", 
"_version": 31, 
"found": true, 
"_source": { 
    "query": { 
     "bool": { 
      "minimum_should_match": 1, 
      "should": { 
       "span_or": { 
        "clauses": [{ 
         "span_multi": { 
          "match": { 
           "regexp": { 
            "message": "doesn't" 
           } 
          } 
         } 
        }] 
       } 
      } 
     } 
    } 
}} 

없이 "하지 않습니다"그리고. 어떻게 아포스트로피와 단어를 찾을 수 있습니다 동시에 다음과 같은 쿼리입니다

curl -XPUT 'localhost:9200/liza_index/.percolator/1' -d '{"query" : {"match" : {"message" : "doesn't"}}}' 

curl -XPUT 'localhost:9200/liza_index/.percolator/1' -d '{"query" : {"match" : {"message" : "doesn\\'t"}}}' 

질문을 사용할 수 있습니까? 첫 번째 쿼리의 구조를 사용하여 어떤 종류의 쿼리를 만들어야합니까?

답변

0

는 "모두의 가장 어려운 점은 어두운 방에 검은 고양이를 찾는 것입니다, 에는 고양이가 없다 특히."

- 공자

Elasticsearch 데이터의 standard analysis and curation을 수행하는 것이 받습니다. 대부분의 구두점을 제거합니다. 과 일치하는 쿼리를 사용하면 동일한 큐 레이션 프로세스를 통해 쿼리를 전달하므로 쿼리에서 모든 구두점이 제거됩니다. 정규 표현식 쿼리는 선별되지 않습니다. 그래서 아포스트로피를 찾을 수 없습니다.

대신 복잡한 정규 표현식 쿼리를 생성하는 당신이 그건, 정규 표현식 패턴을 찾기 위해 puctuation에게

+1

을 보존하기 위해 내가 한 사용 match_phrase

curl -XPOST "http://esarchive.local:9200/liza_index/.percolator/_search" -d' { "query": { "match_phrase": { "message": "find it is disappointing, but true, that there is no tradition in britain of eating in restaurants, because our food doesn\"t" } } }' 

또는 사용자 정의 분석기/매퍼를 만들 수 왜 그럴 수 없어 match_phrase를 사용하십시오 (match_phrase에서 정규 표현식을 사용할 수없는 한 알 수 있습니다). 따라서 토크 나이저 설정을 수정하면 도움이됩니다. 감사합니다. – Shelari

관련 문제