'Elastic/Elasticsearch'에 해당되는 글 385건

  1. 2012.11.14 solr 막 설치 하기.
  2. 2012.04.27 [solr] Indexing & Searching 맛보기 - solr 기초 마지막..
  3. 2012.04.25 [solr] solrconfig.xml 맛보기
  4. 2012.04.24 [solr] schema.xml 맛보기
  5. 2012.04.13 Solr 설치 관련 링크

solr 막 설치 하기.

Elastic/Elasticsearch 2012. 11. 14. 13:00

[solr 공통]

    1. solr 를 다운로드

        http://mirror.apache-kr.org/lucene/solr/4.0.0/apache-solr-4.0.0.tgz

        http://apache.mirror.cdnetworks.com/lucene/solr/3.6.1/apache-solr-3.6.1.tgz

    2. 압축 해제

        tar -xvzf apache-solr-4.0.0.tgz

    3. 압축 해제 후 example 경로로 이동

        cd apache-solr-4.0.0/example

    4. To launch Jetty with the Solr WAR, and the example configs, just run the start.jar ...

        [example]$ java -jar start.jar

    5. 접속해 보기

        http://10.101.254.223:8983/solr

        바로 화면이 뜸

    6. 나머지는 그냥 tutorial 에 나와 있는 데로 그냥 따라만 하면 동작 함.

        http://lucene.apache.org/solr/4_0_0/tutorial.html

        http://lucene.apache.org/solr/api-3_6_1/doc-files/tutorial.html


[solr-3.6.1 / 다중 solr 실행]

    1. tomcat 사용하기

    2. apache-tomcat 다운로드 및 압축 해제

    3. tomcat 아래 디렉토리 만들기

        tomcat/conf/Catalina

        mkdir -p tomcat/conf/Catalina/localhost

        tomcat/data

        tomcat/data/solr

        tomcat/data/solr/dev

        mkdir -p tomcat/data/solr/dev/conf

        mkdir -p tomcat/data/solr/dev/data

        tomcat/data/solr/prod

        mkdir -p tomcat/data/solr/prod/conf

        mkdir -p tomcat/data/solr/prod/data

    4. apache-solr-3.6.1.war 복사

        solr 압축 해제한 경로 내 dist 에 존재

        cp apache-solr-3.6.1/dist/apache-solr-3.6.1.war tomcat/data/solr/

    5. solrdev.xml 생성

        cd tomcat/conf/Catalina/localhost

        <Context docBase="/home/user/app/tomcat/data/solr/apache-solr-3.6.1.war" debug="0" crossContext="true">

            <Environment name="solr/home" type="java.lang.String" value="/home/user/app/tomcat/data/solr/dev" override="true" />

        </Context>

    6. solrprod.xml 생성

        cd /home/user/app/tomcat/conf/Catalina/localhost

        <Context docBase="/home/user/app/tomcat/data/solr/apache-solr-3.6.1.war" debug="0" crossContext="true">

            <Environment name="solr/home" type="java.lang.String" value="/home/user/app/tomcat/data/solr/prod" override="true" />

        </Context>

    7. solr conf 파일 복사

        [conf]$ cp -R * /home/user/app/tomcat/data/solr/dev/conf/

        [conf]$ cp -R * /home/user/app/tomcat/data/solr/prod/conf/

        [conf]$ pwd

        /home/user/app/apache-solr-3.6.1/example/solr/conf


그냥 급하게 막 설치하거구요.
그 이외 설정이랑 색인, 검색등은 이전 글 참고 하시면 되겠습니다.

:

[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!!

:

[solr] solrconfig.xml 맛보기

Elastic/Elasticsearch 2012. 4. 25. 14:42

solr 자체에 대한 설정 파일을 안보고 왔었내요.
solrconfig.xml 파일이 뭐 하는 넘인지 보도록 하겠습니다.

원문은 아래 링크에 있습니다.
다만, solrconfig.xml 파일고 문서를 비교해 보니.. 좀 다르내요.. 
둘다 참고 하셔야 할 듯 합니다.
저는 기냥 solrconfig.xml 파일을 가지고 정리 합니다. ^^;

[solrconfig.xml]
- Solr 설정을 위한 대부분의 정보를 가지고 있다고 하는 군요.

solrconfig.xml is the file that contains most of the parameters for configuring Solr itself.

[lib directive]
- solr plugin 이나 jar 파일들을 loading 하기 위해 사용되는 directive 입니다.
- 아래 주석을 포함한 샘플 코드를 보시면 이해 하기 쉬우실 겁니다.
- 내용에 이런게 있내요, dir 에 매치 되는게 없으면 그냥 무시 하지만 path 로 정확하게 지정 했을 경우 없으면 에러가 난다는군요.

[dataDir directive]
- 절대경로, 상대경로에 주의 해서 사용을 하세요.
- 색인데이터가 위치하는 경로 입니다.

dataDir parameter

Used to specify an alternate directory to hold all index data other than the default ./data under the Solr home. If replication is in use, this should match the replication configuration. If this directory is not absolute, then it is relative to the current working directory of the servlet container.

<!-- Data Directory

       Used to specify an alternate directory to hold all index data
       other than the default ./data under the Solr home.  If
       replication is in use, this should match the replication
       configuration.
    -->
  <dataDir>${solr.data.dir:}</dataDir>

[luceneMatchVersion directive]
- solr 에서 사용하는 lucene 버전을 명시 합니다.

  <!-- Controls what version of Lucene various components of Solr
       adhere to.  Generally, you want to use the latest version to
       get all bug fixes and improvements. It is highly recommended
       that you fully re-index after changing this setting as it can
       affect both how text is indexed and queried.
  --> 

<luceneMatchVersion>LUCENE_40</luceneMatchVersion>

[directoryFactory directive]
- 이건 lucene 에서도 indexWriter 에서 사용하게 되는 내용과 같은 거라고 보시면 됩니다.
- 색인 파일에 대한 file system 이라고 이해 하시고, lucene 에서는 Direcotry Class 를 참고 하시면 됩니다.

<!-- The DirectoryFactory to use for indexes.

       
       solr.StandardDirectoryFactory, the default, is filesystem
       based and tries to pick the best implementation for the current
       JVM and platform.  One can force a particular implementation
       via solr.MMapDirectoryFactory, solr.NIOFSDirectoryFactory, or
       solr.SimpleFSDirectoryFactory.

       solr.RAMDirectoryFactory is memory based, not
       persistent, and doesn't work with replication.
    -->
  <directoryFactory name="DirectoryFactory" 
                    class="${solr.directoryFactory:solr.StandardDirectoryFactory}"/>

[indexConfig directive]
- 이 부분은 색인을 하기 위한 상세 설정을 하게 됩니다.
- 관련 지식이 부족 할 경우 접근하기 매우 어렵습니다. (저는 잘 하냐구요? 후덜덜;;;;)

[jmx directive]
http://wiki.apache.org/solr/SolrJmx

[updateHandler directive] - 어떤 조건하에 commit 수행을 하도록 설정을 합니다. - solr 에서 add/replace/commit/delete 그리고 query 에 의한 delete 시에 사용 되는 것 같습니다. - 주석에 나와 있는 링크 참고하세요.

[indexReaderFactory directive]
- lucene 의 indexReader 와 같은 역할을 하는 거라고 보시면 될 것 같습니다.

<!-- IndexReaderFactory

       Use the following format to specify a custom IndexReaderFactory,
       which allows for alternate IndexReader implementations.

       ** Experimental Feature **

       Please note - Using a custom IndexReaderFactory may prevent
       certain other features from working. The API to
       IndexReaderFactory may change without warning or may even be
       removed from future releases if the problems cannot be
       resolved.


       ** Features that may not work with custom IndexReaderFactory **

       The ReplicationHandler assumes a disk-resident index. Using a
       custom IndexReader implementation may cause incompatibility
       with ReplicationHandler and may cause replication to not work
       correctly. See SOLR-1366 for details.

    -->
  <!--
  <indexReaderFactory name="IndexReaderFactory" class="package.class">
    <str name="someArg">Some Value</str>
  </indexReaderFactory >
  -->
  <!-- By explicitly declaring the Factory, the termIndexDivisor can
       be specified.
    -->
  <!--
     <indexReaderFactory name="IndexReaderFactory" 
                         class="solr.StandardIndexReaderFactory">
       <int name="setTermIndexDivisor">12</int>
     </indexReaderFactory > 

-->

[query directive]
- cache 에 대한 설정과 indexSeacher 에 대한 action 을 설정 합니다.

[requestDispatcher directive]
- /select?qt=xxxx 에 대한 처리를 설정 합니다.
[requestParsers directive]
- solr 가 parsing 하기 위한 설정 또는 제한
[httpCaching directive]
- cache control 설정을 합니다.

[requestHandler & searchHandler directive]
- 이 넘들은 아래 주석에서 처럼 searchHandler 를 한번 보시고 보시면 이해가 쉽습니다.
- 말은 쉽습니다 했으나.. 겁나 어려운 영역 입니다.
- 이 설정을 어떻게 하느냐에 따라서 검색 결과가 막 영향을 받을 테니까요..

[searchComponent directive]
- 이 넘은 searchHandler 대신 사용하는가 봅니다.
- 그리고 requestHandler 랑 조합해서 사용을 하는 군요.
- 역시 이 부분도 설정이 매우 어렵습니다. ㅡ.ㅡ;;

[updateRequestProcessorChain directive]
- update request 에 대한 추가적인 처리가 필요 할때 뭔가 하는 것 같은데 직접 돌려봐야겠내요.

[queryReponseWriter directive]
- response format 을 지정 합니다.

[queryParser, valueSourceParse, transformer, admin directive]
- queryParser 와 valueSourceParse 의 경우는 검색 query 에 대해 처리 하기 위한 내용입니다.
- 아래 URL 참고 하시면 됩니다.


:

[solr] schema.xml 맛보기

Elastic/Elasticsearch 2012. 4. 24. 15:42

[원본링크]


Solr Wiki 에 정의된 내용을 한번 보도록 하죠.

The schema.xml file contains all of the details about which fields your documents can contain, and how those fields should be dealt with when adding documents to the index, or when querying those fields.

- 인덱싱 또는 쿼리 할때 문서의 field 에 대해 자세한 정보를 담고 있는 파일 이라고 되어 있군요.
- 결국, Solr 에서 색인이나 검색 시 문서의 기본 스키마 정보를 제공한다고 보면 됩니다.
- 뭐, 파일 이름도 그렇고 설명도 굳이 제가 설명하지 않아도 누구나 이해가 되는 내용이내요.. ^^;;


[Data Types]

The <types> section allows you to define a list of <fieldtype> declarations you wish to use in your schema, along with the underlying Solr class that should be used for that type, as well as the default options you want for fields that use that type.

- <types> 라는 지시어는 <fieldtype> 의 목록으로 구성 된다고 하는 군요.
- <fieldtype> 정의에 따라서 색인이나 검색 시 구현되는 방법에 영향을 미치게 됩니다.
- 내용이 너무 길어서 몽창 설명 하기는 어렵고.. 링크 참고하세요
- 단, 차분히 schema.xml 파일을 정독해 보시고 주석에 나와 있는 것 처럼 관련 내용들을 한번 씩은 보시는게 이해하는데 아주 좋습니다.


[Fields]
- 이 지시자는 문서를 추가 하거나 검색할때 사용합니다.

The <fields> section is where you list the individual <field> declarations you wish to use in your documents. Each <field> has a name that you will use to reference it when adding documents or executing searches, and an associated type which identifies the name of the fieldtype you wish to use for this field. There are various field options that apply to a field. These can be set in the field type declarations, and can also be overridden at an individual field's declaration.


- 주석에도 설명이 되어 있지만, 위에서 선언한 <fieldtype> 의 name 에 해당하는 label 을 드디어 사용하게 됩니다. 아마도 어디서 사용하는지 궁금 하셨을 수도 있겠내요.

 <!-- Valid attributes for fields:
     name: mandatory - the name for the field
     type: mandatory - the name of a previously defined type from the 
       <types> section
     indexed: true if this field should be indexed (searchable or sortable)
     stored: true if this field should be retrievable
     multiValued: true if this field may contain multiple values per document
     omitNorms: (expert) set to true to omit the norms associated with
       this field (this disables length normalization and index-time
       boosting for the field, and saves some memory).  Only full-text
       fields or fields that need an index-time boost need norms.
       Norms are omitted for primitive (non-analyzed) types by default.
     termVectors: [false] set to true to store the term vector for a
       given field.
       When using MoreLikeThis, fields used for similarity should be
       stored for best performance.
     termPositions: Store position information with the term vector.  
       This will increase storage costs.
     termOffsets: Store offset information with the term vector. This 
       will increase storage costs.
     required: The field is required.  It will throw an error if the
       value does not exist
     default: a value that should be used if no value is specified
       when adding a document.
   -->

- <dynamicField> 이넘은 field name 을 찾지 못하게 되면 특정 패턴에 매칭된 이름을 사용하게 됩니다.


[Unique Key]
- 색인하는 전체 문서에 대한 unique key 로 사용 됩니다.
- 이 Key 값으로 문서를 업데이트 하거나 삭제 하거나 할 수 있겠죠.

The Unique Key Field

The <uniqueKey> declaration can be used to inform Solr that there is a field in your index which should be unique for all documents. If a document is added that contains the same value for this field as an existing document, the old document will be deleted.

It is not mandatory for a schema to have a uniqueKey field.

Note that if you have enabled the QueryElevationComponent in solrconfig.xml it requires the schema to have a uniqueKey of type StrField. It cannot be, for example, an int field.


[기타]
- 기타라고 빼놓았지만 역시 중요한 지시자 입니다.

[defaultSearchField]
- 검색 시 정확한 필드명이 지정되지 않았을 경우 기본 검색 필드로 사용 합니다.

[solrQueryParser]
- AND, OR 오퍼레이션을 정의 합니다.

[copyField]
- source 에 해당하는 field 의 value 를 dest 에 해당하는 field 로 복사 합니다.

[similarity]
- 색인 작업 시 solr 가 사용하는 하위 클래스를 지정하는데 사용 합니다.
- 없다면, Lucene 의 DefaultSimilarity 를 사용합니다.


:

Solr 설치 관련 링크

Elastic/Elasticsearch 2012. 4. 13. 09:21

시간이 되는데로 하나씩 해보기로 했다.
나와의 약속

http://lucene.apache.org/solr/tutorial.html
http://www.tc.umn.edu/~brams006/solr_ubuntu.html
http://wiki.apache.org/solr/SolrInstall
http://wiki.apache.org/solr/SolrTomcat


: