2.X/2. Search in Depth 62

2-4-1. Phrase Matching

In the same way that the match query is the go-to query for standard full-text search, the match_phrase query is the one you should reach for when you want to find words that are near each other:표준 full-text 검색에 대해, match query가 정보를 찾는 query인 것과 동일한 방식으로, match_phrasequery는 서로 가까이 있는 단어들을 찾는 경우에 사용할 query 중 하나이다.GET /my_index/my_type/_search { "query": { "match_phrase": { "title": "quick brown f..

2-4-2. Mixing It Up

Requiring exact-phrase matches may be too strict a constraint. Perhaps we do want documents that contain "quick brown fox" to be considered a match for the query "quick fox", even though the positions aren’t exactly equivalent.정확한 구문 일치를 요구하는 것은 너무 엄격한 제약사항이 될 수 있다. 아마도 "quick brown fox" 를 포함하는 document는 query "quick fox" 에 일치하는 것으로 간주하길 원할 것이다. 비록 그 위치가 정확히 일치하지 않더라도 말이다.We can introduce a degr..

2-4-3. Multivalue Fields

A curious thing can happen when you try to use phrase matching on multivalue fields. Imagine that you index this document:다중 값(multi-value) field에 구문 일치를 사용하는 경우, 특이한 상황이 발생할 수 있다. 아래 document를 색인한다고 가정해 보자.PUT /my_index/groups/1 { "names": [ "John Abraham", "Lincoln Smith"] }COPY AS CURLVIEW IN SENSE Then run a phrase query for Abraham Lincoln:그 다음에, Abraham Lincoln 에 대한 phrase query를 실행해 보자.GE..

2-4-5. Proximity for Relevance

Although proximity queries are useful, the fact that they require all terms to be present can make them overly strict. It’s the same issue that we discussed in Controlling Precision in Full-Text Search: if six out of seven terms match, a document is probably relevant enough to be worth showing to the user, but the match_phrase query would exclude it.proximity query가 유용하지만, 모든 단어가 존재해야 한다는 사실은, 너..

2-4-6. Improving Performance

Phrase and proximity queries are more expensive than simple match queries. Whereas a matchquery just has to look up terms in the inverted index, a match_phrase query has to calculate and compare the positions of multiple possibly repeated terms.phrase와 proximity query는, 단순한 match query에 비해, 더 많은 비용이 든다. match query는 단어를 inverted index에서 찾는 반면에, match_phrase query는 가능한 한 여러 번, 반복해서 단어들의 위치를 계산하고 ..

2-4-7. Finding Associated

As useful as phrase and proximity queries can be, they still have a downside. They are overly strict: all terms must be present for a phrase query to match, even when using slop.phrase와 proximity query는 유용하지만, 단점이 있다. 지나치게 엄격하다. phrase query에 일치하기 위해, 심지어 slop 을 사용할 경우에도, 모든 단어가 반드시 존재해야 한다.The flexibility in word ordering that you gain with slop also comes at a price, because you lose the assoc..

2-5. Partial Matching

A keen observer will notice that all the queries so far in this book have operated on whole terms. To match something, the smallest unit had to be a single term. You can find only terms that exist in the inverted index.눈썰미가 좋은 독자라면, 지금까지 이 책의 모든 query는 전체 단어를 기준으로 동작된다는 것을 알아차렸을 것이다. 어떤 것과 일치한다는 것은, 가장 작은 단위가 단일 단어이어야 한다. inverted index에 존재하는 단어만을 검색할 수 있다.But what happens if you want to match p..

2-5-1. Postcodes and Structured Data

We will use United Kingdom postcodes (postal codes in the United States) to illustrate how to use partial matching with structured data. UK postcodes have a well-defined structure. For instance, the postcode W1V 3DG can be broken down as follows:구조화된 데이터를 가지고, 부분 일치를 사용하는 방법을 설명하기 위해, 영국의 우편번호를 사용할 것이다. 영국의 우편번호는 잘 정의된 구조를 가지고 있다. 예를 들어, 우편번호 W1V 3DG 는 아래와 같이 나누어진다.W1V: This outer part identifie..

2-5-2. prefix Query

To find all postcodes beginning with W1, we could use a simple prefix query:W1 로 시작하는 우편번호를 검색하기 위해, 간단한 prefix query를 사용할 수 있다.GET /my_index/address/_search { "query": { "prefix": { "postcode": "W1" } } }COPY AS CURLVIEW IN SENSE The prefix query is a low-level query that works at the term level. It doesn’t analyze the query string before searching. It assumes that you have passed it the exact ..