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 identifies the postal area and district:W1V: 이 바깥 부분은 우편 지역(area)과 구역(district)을 구분한다.Windicates the area (one or two letters)W지역(area), 하나 또는 두 개의 문자1Vindicates the district (one or two numbers, possibly followed by a letter)1V구역(district), 하나 또는 두 개의 숫자, 문자가 따라올 수 있다.
3DG: This inner part identifies a street or building:3DG: 이 안쪽 부분은 거리나 빌딩을 구분한다.3indicates the sector (one number)3지구(sector), 하나의 숫자DGindicates the unit (two letters)DGunit, 두 개의 문자
Let’s assume that we are indexing postcodes as exact-value not_analyzed fields, so we could create our index as follows:
exact-value not_analyzed field로 우편번호를 색인한다고 가정하고, 다음처럼 index를 생성해 보자.
PUT /my_index { "mappings": { "address": { "properties": { "postcode": { "type": "string", "index": "not_analyzed" } } } } }
PUT /my_index/address/1 { "postcode": "W1V 3DG" } PUT /my_index/address/2 { "postcode": "W2F 8HW" } PUT /my_index/address/3 { "postcode": "W1F 7HW" } PUT /my_index/address/4 { "postcode": "WC1N 1LZ" } PUT /my_index/address/5 { "postcode": "SW5 0BE" }
Now our data is ready to be queried.
이제, 데이터를 검색하기 위한 준비가 되었다.
'2.X > 2. Search in Depth' 카테고리의 다른 글
| 2-4-7. Finding Associated (0) | 2017.09.24 |
|---|---|
| 2-5. Partial Matching (0) | 2017.09.24 |
| 2-5-2. prefix Query (0) | 2017.09.24 |
| 2-5-3. wildcard and regexp Queries (0) | 2017.09.24 |
| 2-5-4. Query-Time Search-as-You-Type (0) | 2017.09.24 |