'lucene'에 해당되는 글 71건

  1. 2013.01.23 lucene kr analyzer flow
  2. 2013.01.22 lucene 튜토리얼
  3. 2013.01.07 Basic Indexing Options for Lucene.
  4. 2013.01.03 elasticsearch plugin 설치하기
  5. 2013.01.03 elasticsearch routing 적용하기 1
  6. 2012.12.18 Elasticsearch 동의어/유의어 사전 활용
  7. 2012.12.10 lucene 색인 옵션
  8. 2012.11.22 Elasticsearch Cluster 구성하기 (shards, replicas)
  9. 2012.11.16 elasticsearch 설치 및 한글형태소분석기 적용 따라하기. 3
  10. 2012.04.27 [solr] Indexing & Searching 맛보기 - solr 기초 마지막..

lucene kr analyzer flow

Elastic/Elasticsearch 2013. 1. 23. 10:43

stopwords 적용을 하다 보니 그냥 심심해서 어떤 workflow 인지 올려봅니다.
뭐 소스 보시면 다 아시는 내용이라 그냥 혼자 저장용으로 활용... ^^


[기본 flow]

KoreanAnalyzer.java        : 문장을 분석하기 위한 Analyzer 구성 (LUCENE.Version 과 stopwords, encoding)

KoreanTokenizer.java       : 지정한 token type 별로 token 분리

KoreanFilter.java              : 입력 받은 token 을 형태소 분석기를 이용해 AnalysisOutput 생성

MorphAnalyzer.java         : 여기서 한국어의 형태소를 분석 (동사, 명사, 조사, 어간, 어미 등등 ) 하여 keyword 추출


[개념적 flow]

KoreanAnalyzer -> KoreanTokenizer -> KoreanFilter -> MorphAnalyzer

:

lucene 튜토리얼

Elastic/Elasticsearch 2013. 1. 22. 18:56

lucene 튜토리얼(추천)
참조 사이트 : http://www.lucenetutorial.com/lucene-in-5-minutes.html

1. https://github.com/macluq/helloLucene에서 HelloLucene-mastsr.zip을 다운로드 받는다.
2. 압축을 해제 한다.
3. 마우스 오른쪽 버튼 -> import -> existing Maven Projects
4. Maven install
5. /src/main/java/HelloLucene/HelloLucene.java 마우스 오른쪽 버튼 Run As > Java Application을 실행

lucene라이브러리를 사용하여 아래의 과정을 보여줌으로써 기본적인 개념을 잡을 수 있도록 도와줌
1. create the index
2. query
3. search
4. display results

:

Basic Indexing Options for Lucene.

Elastic/Elasticsearch 2013. 1. 7. 14:30

아래 내용은 lucene in action 에서 뽑아온 내용입니다.


Field options for indexing
 
The options for indexing (Field.Index.*) control how the text in the field will be
made searchable via the inverted index. Here are the choices:
 
  - Index.ANALYZED—Use the analyzer to break the field’s value into a stream of separate tokens and make each token searchable. This option is useful for normal text fields (body, title, abstract, etc.).
  - Index.NOT_ANALYZED—Do index the field, but don’t analyze the String value. Instead, treat the Field’s entire value as a single token and make that token searchable. This option is useful for fields that you’d like to search on but that shouldn’t be broken up, such as URLs, file system paths, dates, personal names, Social Security numbers, and telephone numbers. This option is especially useful for enabling “exact match” searching. We indexed the id field in listings 2.1 and 2.3 using this option.
  - Index.ANALYZED_NO_NORMS—A variant of Index.ANALYZED that doesn’t store norms information in the index. Norms record index-time boost information in the index but can be memory consuming when you’re searching. Section 2.5.3 describes norms in detail.
  - Index.NOT_ANALYZED_NO_NORMS—Just like Index.NOT_ANALYZED, but also doesn’t store norms. This option is frequently used to save index space and memory usage during searching, because single-token fields don’t need the norms information unless they’re boosted.
  - Index.NO—Don’t make this field’s value available for searching.
Field options for storing fields
 
The options for stored fields (Field.Store.*) determine whether the field’s exact value should be stored away so that you can later retrieve it during searching:
 
  - Store.YES—Stores the value. When the value is stored, the original String in its entirety is recorded in the index and may be retrieved by an IndexReader. This option is useful for fields that you’d like to use when displaying the search results (such as a URL, title, or database primary key). Try not to store very large fields, if index size is a concern, as stored fields consume space in the index.
  - Store.NO—Doesn’t store the value. This option is often used along with Index.ANALYZED to index a large text field that doesn’t need to be retrieved in its original form, such as bodies of web pages, or any other type of text document.
Field options for term vectors
 
  - TermVector.YES—Records the unique terms that occurred, and their counts, in each document, but doesn’t store any positions or offsets information
  - TermVector.WITH_POSITIONS—Records the unique terms and their counts, and also the positions of each occurrence of every term, but no offsets
  - TermVector.WITH_OFFSETS—Records the unique terms and their counts, with the offsets (start and end character position) of each occurrence of every term, but no positions
  - TermVector.WITH_POSITIONS_OFFSETS—Stores unique terms and their counts, along with positions and offsets
  - TermVector.NO—Doesn’t store any term vector information
 
Note that you can’t index term vectors unless you’ve also turned on indexing for the field. Stated more directly: if Index.NO is specified for a field, you must also specify TermVector.NO.
Labels

:

elasticsearch plugin 설치하기

Elastic/Elasticsearch 2013. 1. 3. 14:49


Reference URL

  - 모든 plugin 은 설치 후 plugins 폴더를 복사해서 다른 서버로 옴겨서 설치 가능 함.
  - 사내에서는 사설 IP 사용 시 외부 네트워크 통신에 문제가 있는 경우 복사해서 구성 하면 됨.
bigdesk 설치
  - bin/plugin -install lukas-vlcek/bigdesk
  - http://localhost:9200/_plugin/bigdesk/
head 설치
  - bin/plugin -install Aconex/elasticsearch-head
- bin/plugin -install mobz/elasticsearch-head
  - http://localhost:9200/_plugin/head/
paramedic 설치
  - bin/plugin -install karmi/elasticsearch-paramedic
  - http://localhost:9200/_plugin/paramedic/index.html
kr_analyzer 설치
  - bin/plugin -install chanil1218/elasticsearch-analysis-korean/1.1.0
  - 형태소 분석기의 경우 elasticsearch 0.19.x 을 사용하기 때문에 0.20.x 에서는 오류가 발생 함

:

elasticsearch routing 적용하기

Elastic/Elasticsearch 2013. 1. 3. 14:47

Reference URL

Routing 이란?
  - 색인 시 특정 shard 로 색인을 하고, 검색 시 지정된 shard 로만 검색 할 수 있도록 지원
  - 색인 field 중 unique key 에 해당하는 값을 가지고 routing path 를 지정
  - 검색 시 지정한 path 를 query 에 주어 분산된 indices 를 모두 검색 하지 않고 지정된 indices 만 검색
  - routing field 는 store yes, index not_analyzed 로 설정 되어야 함
 
  - 기본 설정
        "routing" : {
            "required" : true,
            "path" : "test.user_uniq_id"
        }
Routing 설정하기
  - index 생성 시 routing 설정을 포함 시켜 생성 (replica 1, shards 50)
    "settings" : {
        "number_of_shards" : 50,
        "number_of_replicas" : 1,
        "index" : {
            "analysis" : {
                "analyzer" : {
                    "kr_analyzer" : {
                        "type" : "custom",
                        "tokenizer" : "kr_tokenizer",
                        "filter" : ["trim", "kr_filter", "kr_synonym"]
                    },
                    "kr_analyzer" : {
                        "type" : "custom",
                        "tokenizer" : "kr_tokenizer",
                        "filter" : ["trim", "kr_filter", "kr_synonym"]
                    }
                },
                "filter" : {
                    "kr_synonym" : {
                        "type" : "synonym",
                        "synonyms_path" : "analysis/synonym.txt"
                    }
                }
            }
        },
        "routing" : {
            "required" : true,
            "path" : "test.user_uniq_id"
        }
    },
    "mappings" : {
        "test" : {
            "properties" : {
                "docid" : { "type" : "string", "store" : "yes", "index" : "not_analyzed"},
                "title" : { "type" : "string", "store" : "yes", "index" : "analyzed", "term_vector" : "yes", "analyzer" : "kr_analyzer" },
                "user_uniq_id" : { "type" : "string", "store" : "yes", "index" : "not_analyzed" },
                "ymdt" : { "type" : "date", "format" : "yyyyMMddHHmmss", "store" : "yes", "index" : "not_analyzed" }
                }
            }
        }
    }
}'
 
  - document 색인 시 setRouting 설정을 해줘야 정상 동작 함
    IndexRequestBuilder requestBuilder = client.prepareIndex(indexName, indexType);
    requestBuilder.setId(docId);
    requestBuilder.setRouting(docMeta.getUserUniqId());
    requestBuilder.setSource(jsonBuilder);
routing search query uri
  - http://localhost:9200/index0/_search?source={"query":{"bool":{"must":[{"term":{"user_uniq_id":"honggildong@elastic.com"}}],"must_not":[],"should":[]}},"from":0,"size":50,"sort":[{"ymdt":"asc"}],"facets":{}}&routing=honggildong@elastic.com&pretty=true




:

Elasticsearch 동의어/유의어 사전 활용

Elastic/Elasticsearch 2012. 12. 18. 22:22

[title=Elasticsearch 동의어/유의어 설정]

- 색인 파일 생성 시 설정을 해줘야 함

- 기본 kr_analysis 가 적용되어 있어야 함

  - 없을 경우 한국어 처리가 안됨

- synonym.txt 파일을 적절한 위치에 생성

  - http://www.elasticsearch.org/guide/reference/index-modules/analysis/synonym-tokenfilter.html


[title=synonym.txt 샘플]

Solr synonyms


The following is a sample format of the file:


# blank lines and lines starting with pound are comments.


#Explicit mappings match any token sequence on the LHS of "=>"

#and replace with all alternatives on the RHS.  These types of mappings

#ignore the expand parameter in the schema.

#Examples:

i-pod, i pod => ipod,

sea biscuit, sea biscit => seabiscuit


#Equivalent synonyms may be separated with commas and give

#no explicit mapping.  In this case the mapping behavior will

#be taken from the expand parameter in the schema.  This allows

#the same synonym file to be used in different synonym handling strategies.

#Examples:

ipod, i-pod, i pod

foozball , foosball

universe , cosmos


# If expand==true, "ipod, i-pod, i pod" is equivalent to the explicit mapping:

ipod, i-pod, i pod => ipod, i-pod, i pod

# If expand==false, "ipod, i-pod, i pod" is equivalent to the explicit mapping:

ipod, i-pod, i pod => ipod


#multiple synonym mapping entries are merged.

foo => foo bar

foo => baz

#is equivalent to

foo => foo bar, baz


[색인파일 생성 샘플코드 - synonym 적용]

curl -XPUT 'http://localhost:9200/test' -d '{

    "settings" : {

        "number_of_shards" : 5,

        "number_of_replicas" : 1,

        "index" : {

            "analysis" : {

                "analyzer" : {

                    "kr_analyzer" : {

                        "type" : "custom",

                        "tokenizer" : "kr_tokenizer",

                        "filter" : ["trim", "kr_filter", "kr_synonym"]

                    },

                    "kr_analyzer" : {

                        "type" : "custom",

                        "tokenizer" : "kr_tokenizer",

                        "filter" : ["trim", "kr_filter", "kr_synonym"]

                    }

                },

                "filter" : {

                    "kr_synonym" : {

                        "type" : "synonym",

                        "synonyms_path" : "analysis/synonym.txt"

                    }

                }

            }

        }

    }'


[title=색인파일 생성 샘플코드]

curl -XPUT 'http://10.101.254.223:9200/test' -d '{

    "settings" : {

        "number_of_shards" : 5,

        "number_of_replicas" : 1

    },

    "index" : {

        "analysis" : {

            "analyzer" : {

                "synonym" : {

                    "tokenizer" : "kr_analyzer",

                    "filter" : ["synonym"]

                }

            },

            "filter" : {

                "synonym" : {

                    "type" : "synonym",

                    "synonyms_path" : "/home/계정/apps/elasticsearch/plugins/analysis-korean/analysis/synonym.txt"

                }

            }

        }

    },

    "mappings" : {

        "docs" : {

            "properties" : {

 ...................................(요기 부분은 다른 문서들 참고 하시면 됩니다.)

                    }

                }

            }

        }

    }

}'

:

lucene 색인 옵션

Elastic/Elasticsearch 2012. 12. 10. 10:50

짧게 정리...

※ Store 옵션
데이터를 저장 할지에 대한 정의.
결국, 검색 후 화면에 출력을 할 것인지 말 것인지에 따라 정의.

Store.YES : 저장 함
Store.NO : 저장 안함 
Store.COMPRESS : 압축 저장 함 (글 내용이 크거나, binary 파일)


※ Index 옵션
검색을 위한 색인을 할지에 대한 정의.
아래는 2.x 대 내용이니 패스, 4.0 을 보면 전부 deprecated 된 걸로 나오내요.
그래도 의미는 파악 하고 있음 좋겠죠.

Index.NO : 색인을 하지 않음 (검색 field 로 사용하지 않음)
Index.TOKENIZED : 검색 가능 하도록 색인 함, analyzer 에 의한 tokenized 수행을 통해 색인을 함.
Index.UN_TOKENIZED : 검색 가능 하도록 색인 함, 단 analyzer 에 의한 분석을 하지 않기 때문에 색인 속도가 빠름. (숫자나 분석이 필요 없는 경우)
Index.NO_NORMS : 검색 가능 하도록 색임 함, 단 색인 속도가 매우 빨라야 할 경우 사용하며, analyzer 에 의한 분석을 수행 하지 않고, field length normalize 를 수행 하지 않음.


http://lucene.apache.org/core/4_0_0/core/index.html

Enum Constant and Description
ANALYZED
Deprecated. 
Index the tokens produced by running the field's value through an Analyzer.
ANALYZED_NO_NORMS
Deprecated. 
Expert: Index the tokens produced by running the field's value through an Analyzer, and also separately disable the storing of norms.
NO
Deprecated. 
Do not index the field value.
NOT_ANALYZED
Deprecated. 
Index the field's value without using an Analyzer, so it can be searched.
NOT_ANALYZED_NO_NORMS
Deprecated. 
Expert: Index the field's value without an Analyzer, and also disable the indexing of norms.

:

Elasticsearch Cluster 구성하기 (shards, replicas)

Elastic/Elasticsearch 2012. 11. 22. 17:34

많이 부족하지만 일단 스스로 정리하기 위해서.. 올립니다. ^^;

[Reference]

    http://www.elasticsearch.org

    http://www.elasticsearchtutorial.com/elasticsearch-in-5-minutes.html


[URI Command]

    http://10.101.254.223:9200/_status

    http://10.101.254.223:9200/_cluster/state?pretty=true

    http://10.101.254.223:9200/_cluster/nodes?pretty=true

    http://10.101.254.223:9200/_cluster/health?pretty=true


[색인파일 setting 확인]

    http://10.101.254.223:9200/depth1_1/_settings?pretty=true


[색인파일 mapping 확인]

    http://10.101.254.223:9200/depth1_1/_mapping?pretty=true


[색인파일의 URI Step 정의]

    /depth1/

        index 명 (각 서비스 단위의 색인명 or vertical service 명)

        예)

            /blog

            /cafe

    /depth1/depth2/

        index type 명

        예)

            /blog/user

            /blog/post

            /cafe/user

            /cafe/post

    /depth1/depth2/depth3

        색인된 document unique key (id)


[색인파일의 생성, shard, replica 설정]

    http://www.elasticsearch.org/guide/reference/api/admin-indices-create-index.html


    - case 1

        curl -XPUT 'http://10.101.254.221:9200/depth1/'


    - case 2

        curl -XPUT 'http://10.101.254.221:9200/depth1_2/' -d '

        index :

            number_of_shards : 3

            number_of_replicas : 2

        '


    - case 3 : recommended

        curl -XPUT 'http://10.101.254.223:9200/depth1_1/' -d '{

            "settings" : {

                "index" : {

                    "number_of_shards" : 3,

                    "number_of_replicas" : 2

                }

            }

        }'


    - case 4

        curl -XPUT 'http://10.101.254.223:9200/depth1_1/' -d '{

            "settings" : {

                "number_of_shards" : 3,

                "number_of_replicas" : 2

            }

        }'


[색인파일 mapping 설정]

    http://www.elasticsearch.org/guide/reference/mapping/

    http://www.elasticsearch.org/guide/reference/mapping/core-types.html

    ※ 이 영역에서 색인 또는 검색 시 사용할 analyzer 나 tokenizer 를 지정 한다.

    ※ solr 의 경우 schema.xml 에서 정의 하는 설정을 여기서 수행 함.


    curl -XPUT 'http://10.101.254.223:9200/depth1_1/depth2_1/_mapping' -d '

    {

        "depth2_1" : {

            "properties" : {

                "FIELD명" : {"type" : "string", "store" : "yes"}

            }

        }

    }'


[데이터 색인]

    http://www.elasticsearch.org/guide/reference/api/index_.html


    curl -XPUT 'http://10.101.254.223:9200/blog/user/dilbert' -d '{ "name" : "Dilbert Brown" }'


    curl -XPUT 'http://10.101.254.223:9200/blog/post/1' -d '

    {

        "user": "dilbert",

        "postDate": "2011-12-15",

        "body": "Search is hard. Search should be easy." ,

        "title": "On search"

    }'


    curl -XPUT 'http://10.101.254.223:9200/blog/post/2' -d '

    {

        "user": "dilbert",

        "postDate": "2011-12-12",

        "body": "Distribution is hard. Distribution should be easy." ,

        "title": "On distributed search"

    }'


    curl -XPUT 'http://10.101.254.223:9200/blog/post/3' -d '

    {

        "user": "dilbert",

        "postDate": "2011-12-10",

        "body": "Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat" ,

        "title": "Lorem ipsum"

    }'


    curl -XPUT 'http://10.101.254.223:9200/blog/post/4' -d '

    {

        "user": "dilbert",

        "postDate": "2011-12-11",

        "body": "한글 형태소 분석기 테스트와 shard 그리고 replica 테스트" ,

        "title": "elastic search 분산설정"

    }'


    curl -XGET 'http://10.101.254.223:9200/blog/user/dilbert?pretty=true'

    curl -XGET 'http://10.101.254.221:9200/blog/post/1?pretty=true'

    curl -XGET 'http://10.101.254.223:9200/blog/post/2?pretty=true'

    curl -XGET 'http://10.101.254.221:9200/blog/post/3?pretty=true'


[검색테스트]

    http://www.elasticsearch.org/guide/reference/api/search/uri-request.html

    - user에 dilbert 가 포함되어 있는 것

    curl 'http://10.101.254.221:9200/blog/post/_search?q=user:dilbert&pretty=true'

    http://10.101.254.223:9200/blog/post/_search?q=user:dilbert&pretty=true


    - title 에 search 가 포함 안된 것

    curl 'http://10.101.254.223:9200/blog/post/_search?q=-title:search&pretty=true'

    http://10.101.254.223:9200/blog/post/_search?q=-title:search&pretty=true


    - title 에 search 는 있고 distributed 는 없는 것

    curl 'http://10.101.254.223:9200/blog/post/_search?q=+title:search%20-title:distributed&pretty=true&fields=title'

    http://10.101.254.223:9200/blog/post/_search?q=+title:search%20-title:distributed&pretty=true&fields=title


    - range 검색

    curl -XGET 'http://10.101.254.223:9200/blog/_search?pretty=true' -d '

    {

        "query" : {

            "range" : {

                "postDate" : { "from" : "2011-12-10", "to" : "2011-12-12" }

            }

        }

    }'


    - blog 라는 색인 파일 전체 검색

        http://10.101.254.223:9200/blog/_search?q=user:dilbert&pretty=true

        http://10.101.254.223:9200/blog/_search?q=name:dilbert&pretty=true


    - routing 검색 (정확한 의미 파악이 어려움)

        http://10.101.254.223:9200/blog/_search?routing=dilbert?prettry=true


[Clustering 설정 정보]

    ※ 서버1

        cluster.name: cluster_es1

        node.name: node_es1

        node.master: true

        node.data: true

        node.rack: rack_es1

        index.number_of_shards: 3

        index.number_of_replicas: 2

        network.host: 10.101.254.223

        transport.tcp.port: 9300

        http.port: 9200

        gateway.type: local

        gateway.recover_after_nodes: 1

        gateway.recover_after_time: 5m

        gateway.expected_nodes: 2

        cluster.routing.allocation.node_initial_primaries_recoveries: 4

        cluster.routing.allocation.node_concurrent_recoveries: 2

        indices.recovery.max_size_per_sec: 0

        indices.recovery.concurrent_streams: 5

        discovery.zen.minimum_master_nodes: 1

        discovery.zen.ping.timeout: 3s

        discovery.zen.ping.unicast.hosts: ["10.101.254.223:9300", "10.101.254.221:9300"]

        cluster.routing.allocation.allow_rebalance: "indices_all_active"

        indices.recovery.concurrent_streams: 3

        action.auto_create_index: true

        index.mapper.dynamic: true


    ※ 서버2

        cluster.name: cluster_es1

        node.name: node_es2

        node.master: true

        node.data: true

        node.rack: rack_es1

        index.number_of_shards: 3

        index.number_of_replicas: 2

        network.host: 10.101.254.221

        transport.tcp.port: 9300

        http.port: 9200

        gateway.type: local

        gateway.recover_after_nodes: 1

        gateway.recover_after_time: 5m

        gateway.expected_nodes: 2

        cluster.routing.allocation.node_initial_primaries_recoveries: 4

        cluster.routing.allocation.node_concurrent_recoveries: 2

        indices.recovery.max_size_per_sec: 0

        indices.recovery.concurrent_streams: 5

        discovery.zen.minimum_master_nodes: 1

        discovery.zen.ping.timeout: 3s

        discovery.zen.ping.unicast.hosts: ["10.101.254.223:9300", "10.101.254.221:9300"]

        cluster.routing.allocation.allow_rebalance: "indices_all_active"

        indices.recovery.concurrent_streams: 3

        action.auto_create_index: true

        index.mapper.dynamic: true


[설정파일의미]

    ※ 클러스터링할 그룹명 (묶고자 하는 서버들에 elasticsearch.yml 파일에서 이름을 동일하게 주면 클러스터링 됨)

        cluster.name: group1


    ※ 검색 및 색인 서버로 사용하고자 할 경우 설정

        node.master: true

        node.data : true


    ※ 검색 전용 서버로 사용하고자 할 경우 설정 (검색 로드발라서)

        node.master: false

        node.data : false


    ※ 색인 전용 서버로 사용하고자 할 경우 설정

        node.master: false

        node.data : true


    ※ 이건 용도를 잘 모르겠음

        node.master: true

        node.data : false


    ※ 색인 파일(데이터) 사이즈가 작을 경우 수치를 작게 (1), 사이즈가 클 경우 수치를 크게 (기본 5)

    ※ 하나의 색인 파일을 몇 개로 나눠서 저장할 것인지 정의

        index.number_of_shards: 5


    ※ 색인 파일에 대한 복사본 생성 수치 (기본 1)

        index.number_of_replicas: 1


    ※ 설정 후 서버간 클러스터링 되는 과정을 파악하기 어려움

        두 대의 서버에 cluster.name 을 같게 해서 실행 시켜면 자동으로 clustering 됨


    ※ 서버 한대에서 여러개의 elasticsearch instacne 실행 방법

        ./elasticsearch -p pidfile1 -Des.config=elasticsearch/config/elasticsearch1.yml

        ./elasticsearch -p pidfile2 -Des.config=elasticsearch/config/elasticsearch2.yml


        ※ 기타 옵션

        -Xmx1g -Xms1g -Des.max-open-files=true


    ※ node 의 의미

        elasticsearch 에서 node == index 에 의미를 가짐

:

elasticsearch 설치 및 한글형태소분석기 적용 따라하기.

Elastic/Elasticsearch 2012. 11. 16. 13:03

[ElasticSearch 설치하기]

    ※ 참고 URL

    http://www.elasticsearch.org/tutorials/2010/07/01/setting-up-elasticsearch.html

    http://mimul.com/pebble/default/2012/02/23/1329988075236.html

    https://github.com/chanil1218/elasticsearch-analysis-korean

    http://apmlinux.egloos.com/2976457


    ※ 다운로드

    wget --no-check-certificate https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.19.11.tar.gz


    ※ 압축해제

    tar -xvzf elasticsearch-0.19.11.tar.gz


    ※ 링크생성

    ln -s elasticsearch-0.19.11 elasticsearch


    ※ 설정

    cd elasticsearch/config

    vi elasticsearch.yml

        # cluster.name: elasticsearch

        cluster.name: MyCluster


        # network.host: 192.168.0.1

        network.host: 10.101.254.223


        # http.port: 9200

        http.port: 9200


    ※ 실행

    bin/elasticsearch -f

    OR

    bin/elasticsearch -p pidfile


    ※ 기능확인

    curl -X GET http://10.101.254.223:9200/


    ※ 관리툴설치

    bin/plugin -install mobz/elasticsearch-head

    http://10.101.254.223:9200/_plugin/head/


    ※ 한글형태소분석기설치

    bin/plugin -install chanil1218/elasticsearch-analysis-korean/1.1.0


    ※ 한글형태소분석기 설정 (elasticsearch 재실행 후 설정)

    curl -XPUT http://10.101.254.223:9200/test  -d '{

    "settings" : {

        "index": {

            "analysis": {

                "analyzer": {

                    "kr_analyzer": {

                        "type": "custom"

                            , "tokenizer": "kr_tokenizer"

                            ,"filter" : ["trim","kr_filter"]

                    }

                    , "kr_analyzer": {

                        "type": "custom"

                            , "tokenizer": "kr_tokenizer"

                            ,"filter" : ["trim","kr_filter"]

                    }

                }

            }

        }

    }

    }'


    ※ 한글형태소분석기 테스트

    curl -XGET 'http://10.101.254.223:9200/test/_analyze?analyzer=kr_analyzer&pretty=true' -d '전주비빔밥'

        ※ 한글형태소분석결과

        {

          "tokens" : [ {

            "token" : "전주비빔밥",

            "start_offset" : 0,

            "end_offset" : 5,

            "type" : "word",

            "position" : 1

          }, {

            "token" : "전주",

            "start_offset" : 0,

            "end_offset" : 2,

            "type" : "word",

            "position" : 2

          }, {

            "token" : "비빔밥",

            "start_offset" : 2,

            "end_offset" : 5,

            "type" : "word",

            "position" : 3

          } ]

        }

:

[solr] Indexing & Searching 맛보기 - solr 기초 마지막..

Elastic/Elasticsearch 2012. 4. 27. 12:16

가장 중요한 설정 파일 두가지에 대해서 살펴 보았습니다.
solrconfig.xml 과 schema.xml 
아주 중요한 내용들을 설정 하기 때문에 지속적인 학습과 연구가 필요 합니다.
공부합시다.. ㅎㅎ

기본적으로는 아래 문서 보시면 쉽게 이해를 하실 수 있습니다.

우선 post.jar 를 분석해 보겠습니다.
post.jar 를 풀어 보면 SimplePostTool.class 가 들어가 있습니다.

[SimplePostTool.java]
- 이 파일은 package 내 dependency 가 없습니다.
- 그냥 가져다가 사용을 하셔도 됩니다. 
- 저는 solr + tomcat 구성으로 해서 http://localhost:8080/solrdev/update 로 코드 상에 설정 값을 변경했습니다.
- 그럼 색인할 데이터는 어디서 가져와??? 
- 보통은 DB 에 content 를 저장하고 있죠, DB 에 있는 데이터를 select 해 와서 solr 에서 요구하는 format 으로 파일을 생성 하시면 됩니다. xml 을 많이 사용하니 select 해 온 데이터를 xml 파일로 생성 하시면 됩니다.
- 저는 그냥 java project 하나 생성해서 색인할 url 변경하고 SimplePostTool.java 를 다시 묶었습니다.

- 제가 실행시켜 본 화면 입니다.
- 위에 보시면 Main-Class 어쩌구 에러 보이시죠.. 
- MANIFEST 파일을 만들어서 넣어 주시면 됩니다, 중요한건 보이시죠.. 제일 뒤에 개행을 꼭 해주셔야 합니다.

- 그리고 검색을 해보죠.
- 검색 쿼리는 belkin 입니다.

- 참 색인 데이터를 안봤군요.

[ipod_other.xml]
- solr 설치 하시면 example/exampledocs/ 아래 들어 있습니다.

<!--

 Licensed to the Apache Software Foundation (ASF) under one or more

 contributor license agreements.  See the NOTICE file distributed with

 this work for additional information regarding copyright ownership.

 The ASF licenses this file to You under the Apache License, Version 2.0

 (the "License"); you may not use this file except in compliance with

 the License.  You may obtain a copy of the License at


     http://www.apache.org/licenses/LICENSE-2.0


 Unless required by applicable law or agreed to in writing, software

 distributed under the License is distributed on an "AS IS" BASIS,

 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

 See the License for the specific language governing permissions and

 limitations under the License.

-->

<add>

<doc>

  <field name="id">F8V7067-APL-KIT</field>

  <field name="name">Belkin Mobile Power Cord for iPod w/ Dock</field>

  <field name="manu">Belkin</field>

  <field name="cat">electronics</field>

  <field name="cat">connector</field>

  <field name="features">car power adapter, white</field>

  <field name="weight">4</field>

  <field name="price">19.95</field>

  <field name="popularity">1</field>

  <field name="inStock">false</field>

  <!-- Buffalo store -->

  <field name="store">45.17614,-93.87341</field>

  <field name="manufacturedate_dt">2005-08-01T16:30:25Z</field>

</doc>

<doc>

  <field name="id">IW-02</field>

  <field name="name">iPod &amp; iPod Mini USB 2.0 Cable</field>

  <field name="manu">Belkin</field>

  <field name="cat">electronics</field>

  <field name="cat">connector</field>

  <field name="features">car power adapter for iPod, white</field>

  <field name="weight">2</field>

  <field name="price">11.50</field>

  <field name="popularity">1</field>

  <field name="inStock">false</field>

  <!-- San Francisco store -->

  <field name="store">37.7752,-122.4232</field>

  <field name="manufacturedate_dt">2006-02-14T23:55:59Z</field>

</doc>

</add>

- 검색 결과 화면 입니다.


자, 지금까지 solr 설치, 설정, 색인과 검색을 맛보기로 해봤습니다.
이제 부터는 각자 열공하셔서 필요한 만큼 사용하시면 될것 같습니다.


Good luck!!

: