| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- <sect1 id="zend.search.lucene.java-lucene">
- <title>Взаимодействие с Java Lucene<!--Interoperating with Java Lucene--></title>
- <sect2 id="zend.search.lucene.index-creation.file-formats">
- <title>Форматы файлов<!--File Formats--></title>
- <para>
- Форматы файлов индекса Zend_Search_Lucene являются совместимыми с Lucene
- версии 1.4 и выше.
- <!--
- Zend_Search_Lucene index file formats are binary compatible with a Lucene
- version 1.4 and above.
- -->
- </para>
- <para>
- Подробное описание этого формата можно прочитать здесь:
- <!--
- A detailed description of this format is available here:
- -->
- <ulink url="http://lucene.apache.org/java/docs/fileformats.html"/>.
- </para>
- </sect2>
- <sect2 id="zend.search.lucene.index-creation.index-directory">
- <title>Директория для индекса<!--Index Directory--></title>
- <para>
- После создания индекса директория для индекса будет содержать несколько файлов:
- <!--
- After index creation, the index directory will contain several files:
- -->
- </para>
- <itemizedlist>
- <listitem>
- <para>
- файл <filename>segments</filename> является списком сегментов индекса.
- <!--
- <filename>segments</filename> file is a list of index segments.
- -->
- </para>
- </listitem>
- <listitem>
- <para>
- файлы <filename>*.cfs</filename> содержат сегменты индекса.
- Внимание! Оптимизированный индекс всегда имеет только один сегмент.
- <!--
- <filename>*.cfs</filename> files contain index segments.
- Note! Optimized index has always only one segment.
- -->
- </para>
- </listitem>
- <listitem>
- <para>
- файл <filename>deletable</filename> является списком файлов,
- которые больше не используются индексом, но которые нельзя было удалить.
- <!--
- <filename>deletable</filename> file is a list of files that are no longer used
- by the index, but which could not be deleted.
- -->
- </para>
- </listitem>
- </itemizedlist>
- </sect2>
- <sect2 id="zend.search.lucene.java-lucene.source-code">
- <title>Исходный код Java<!--Java Source Code--></title>
- <para>
- Приведенный ниже листинг программы на Java представляет собой пример
- того, как индексировать файл, используя Java Lucene:
- <!--
- The Java program listing below provides an example of how to index a file
- using Java Lucene:
- -->
- </para>
- <programlisting language="java"><![CDATA[
- /**
- * Создание индекса:
- */
- import org.apache.lucene.index.IndexWriter;
- import org.apache.lucene.document.*;
- import java.io.*
- ...
- IndexWriter indexWriter = new IndexWriter("/data/my_index",
- new SimpleAnalyzer(), true);
- ...
- String filename = "/path/to/file-to-index.txt"
- File f = new File(filename);
- Document doc = new Document();
- doc.add(Field.Text("path", filename));
- doc.add(Field.Keyword("modified",DateField.timeToString(f.lastModified())));
- doc.add(Field.Text("author", "unknown"));
- FileInputStream is = new FileInputStream(f);
- Reader reader = new BufferedReader(new InputStreamReader(is));
- doc.add(Field.Text("contents", reader));
- indexWriter.addDocument(doc);]]>
- </programlisting>
- </sect2>
- </sect1>
- <!--
- vim:se ts=4 sw=4 et:
- -->
|