Programing

Elastic Search : 인덱싱 된 데이터를 보는 방법

lottogame 2020. 8. 21. 08:20
반응형

Elastic Search : 인덱싱 된 데이터를 보는 방법


attr_protected로 인해 일부 데이터가 제대로 인덱싱되지 않은 ElasticSearch 및 Rails에 문제가 발생했습니다. Elastic Search는 인덱싱 된 데이터를 어디에 저장합니까? 실제 인덱싱 된 데이터가 잘못된 지 확인하는 것이 유용합니다.

로 매핑을 확인해도 Tire.index('models').mapping도움이되지 않으며 필드가 나열됩니다.


ElasticSearch 클러스터를 탐색하는 가장 쉬운 방법은 elasticsearch-head 를 사용하는 것 입니다.

다음을 수행하여 설치할 수 있습니다.

cd elasticsearch/
./bin/plugin -install mobz/elasticsearch-head

그런 다음 (ElasticSearch가 이미 로컬 컴퓨터에서 실행되고 있다고 가정) 브라우저 창을 열어 다음을 수행합니다.

http://localhost:9200/_plugin/head/

또는 curl명령 줄에서 사용할 수 있습니다 . 예 :

인덱스에 대한 매핑을 확인하십시오.

curl -XGET 'http://127.0.0.1:9200/my_index/_mapping?pretty=1' 

샘플 문서 받기 :

curl -XGET 'http://127.0.0.1:9200/my_index/_search?pretty=1' 

특정 필드에 저장된 실제 용어를 참조하십시오 (예 : 해당 필드가 분석 된 방법).

curl -XGET 'http://127.0.0.1:9200/my_index/_search?pretty=1'  -d '
 {
    "facets" : {
       "my_terms" : {
          "terms" : {
             "size" : 50,
             "field" : "foo"
          }
       }
    }
 }

자세한 내용은 http://www.elasticsearch.org/guide를 참조 하십시오.

업데이트 : Marvel의 Sense 플러그인

curlElasticsearch에 대한 스타일 명령을 작성하는 가장 쉬운 방법은 MarvelSense 플러그인입니다 .

소스 강조 표시, 예쁜 들여 쓰기 및 자동 완성 기능이 함께 제공됩니다.

참고 : Sense는 원래 독립형 크롬 플러그인 이었지만 이제는 Marvel 프로젝트의 일부입니다 .


색인 된 데이터를 보는 가장 쉬운 방법은 브라우저에서 보는 것입니다. 다운로드 나 설치가 필요하지 않습니다.

귀하의 elasticsearch 호스트가 http://127.0.0.1:9200.

1 단계

http://127.0.0.1:9200/_cat/indices?v인덱스를 나열 하려면 이동 하십시오. 다음과 같은 내용이 표시됩니다.

여기에 이미지 설명 입력

2 단계

원하는 색인에 액세스 해보십시오. http://127.0.0.1:9200/products_development_20160517164519304

출력은 다음과 같습니다.

여기에 이미지 설명 입력

주목 aliases우리는뿐만 아니라에서 인덱스에 액세스 할 수 있습니다 의미 :http://127.0.0.1:9200/products_development

3 단계

http://127.0.0.1:9200/products_development/_search?pretty=1데이터를 보려면로 이동 하십시오.

여기에 이미지 설명 입력


ElasticSearch 데이터 브라우저

검색, 차트, 원 클릭 설정 ....


집계 솔루션

데이터를 그룹화하여 문제 해결-DrTech의 답변 이를 관리하는 데 측면을 사용했지만 Elasticsearch 1.0 참조에 따라 더 이상 사용되지 않습니다.

Warning

Facets are deprecated and will be removed in a future release. You are encouraged to
migrate to aggregations instead.

패싯은 집계로 대체됩니다 . Elasticsearch 가이드에서 액세스 가능한 방식으로 도입되어 예제를 의미있게로드합니다. .

짧은 솔루션

용액을 필요한 집계 제외한 동일 aggs대신 facets과 함께 최대 정수에 한계를 설정 0 카운트 - 예 코드 놀라운 플러그인 필요

# Basic aggregation
GET /houses/occupier/_search?search_type=count
{
    "aggs" : {
        "indexed_occupier_names" : {    <= Whatever you want this to be
            "terms" : {
              "field" : "first_name",    <= Name of the field you want to aggregate
              "size" : 0
            }
        }
    }
}

전체 솔루션

Here is the Sense code to test it out - example of a houses index, with an occupier type, and a field first_name:

DELETE /houses

# Index example docs
POST /houses/occupier/_bulk
{ "index": {}}
{ "first_name": "john" }
{ "index": {}}
{ "first_name": "john" }
{ "index": {}}
{ "first_name": "mark" }


# Basic aggregation
GET /houses/occupier/_search?search_type=count
{
    "aggs" : {
        "indexed_occupier_names" : {
            "terms" : {
              "field" : "first_name",
              "size" : 0
            }
        }
    }
}

Response

Response showing the relevant aggregation code. With two keys in the index, John and Mark.

    ....
    "aggregations": {
      "indexed_occupier_names": {
         "buckets": [
            {
               "key": "john",     
               "doc_count": 2     <= 2 documents matching
            },                        
            {
               "key": "mark",
               "doc_count": 1     <= 1 document matching
            }
         ]
      }
   }
   ....

A tool that helps me a lot to debug ElasticSearch is ElasticHQ. Basically, it is an HTML file with some JavaScript. No need to install anywhere, let alone in ES itself: just download it, unzip int and open the HTML file with a browser.

Not sure it is the best tool for ES heavy users. Yet, it is really practical to whoever is in a hurry to see the entries.


If you are using Google Chrome then you can simply use this extension named as Sense it is also a tool if you use Marvel.

https://chrome.google.com/webstore/detail/sense-beta/lhjgkmllcaadmopgmanpapmpjgmfcfig


@JanKlimo 예제에 따라 터미널에서해야 할 일은 다음과 같습니다.

모든 색인을 보려면 : $ curl -XGET 'http://127.0.0.1:9200/_cat/indices?v'

Index 내용보기 products_development_20160517164519304: $ curl -XGET 'http://127.0.0.1:9200/products_development_20160517164519304/_search?pretty=1'


Kibana는 또한 좋은 솔루션입니다. Elastic 용 데이터 시각화 플랫폼으로, 설치된 경우 기본적으로 포트 5601에서 실행됩니다.

그것이 제공하는 많은 것 중에서. 디버깅을 수행 할 수있는 "Dev Tools"가 있습니다.

예를 들어 여기에서 다음 명령을 사용하여 사용 가능한 색인을 확인할 수 있습니다.

GET /_cat/indices

참고 URL : https://stackoverflow.com/questions/8954785/elastic-search-how-to-see-the-indexed-data

반응형