lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wai Wong (JIRA)" <j...@apache.org>
Subject [jira] Commented: (LUCENE-1881) Non-stored fields are not copied in writer.addDocument()?
Date Wed, 02 Sep 2009 07:36:32 GMT

    [ https://issues.apache.org/jira/browse/LUCENE-1881?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12750315#action_12750315
] 

Wai Wong commented on LUCENE-1881:
----------------------------------

Thanks.  I just checked Searcher and forgot to check IndexSearcher.  I shall try this out
and see if the performance is ok, especially the overhead in adding new entries and optimizing/merging
the indexes.

If not, I would turn back and use my own way of buffering the non-Stored fields.

Thanks for the support.

> Non-stored fields are not copied in writer.addDocument()?
> ---------------------------------------------------------
>
>                 Key: LUCENE-1881
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1881
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Store
>    Affects Versions: 2.4.1
>         Environment: Linux
>            Reporter: Wai Wong
>            Assignee: Hoss Man
>            Priority: Critical
>
> We would like to modified stored documents properties.  The method is to use IndexReader
to open all files, modified some fields, and copy the document via addDocument() of IndexWriter
to another index.  But all fields that are created using Field.Store.NO are no longer available
for searching.
> Sample code in jsp is attached:
> <%@ page language="java" import="org.apache.lucene.analysis.standard.StandardAnalyzer;"%>
> <%@ page language="java" import="org.apache.lucene.document.*;"%>
> <%@ page language="java" import="org.apache.lucene.index.*;"%>
> <%@ page language="java" import="org.apache.lucene.search.*;"%>
> <%@ page contentType="text/html; charset=utf8" %>
> <%
>     // create for testing
>     IndexWriter writer = new IndexWriter("/opt/wwwroot/351/Index/test", new StandardAnalyzer(),
true, IndexWriter.MaxFieldLength.LIMITED);
>     Document doc = new Document();
>     doc.add(new Field("A", "1234", Field.Store.NO , Field.Index.NOT_ANALYZED));
>     doc.add(new Field("B", "abcd", Field.Store.NO , Field.Index.NOT_ANALYZED));
>     writer.addDocument(doc);
>     writer.close();
>     // check ok
>     Query q = new TermQuery(new Term("A", "1234"));
>     Searcher s = new IndexSearcher("/opt/wwwroot/351/Index/test");
>     Hits h = s.search(q);
>     out.println("# of document found is " + h.length());        // it is ok
>     // update the document to change or remove a field
>     IndexReader r = IndexReader.open("/opt/wwwroot/351/Index/test");
>     doc = r.document(0);
>     r.deleteDocument(0);
>     r.close();
>     doc.removeField("B");
>     writer = new IndexWriter("/opt/wwwroot/351/Index/test1", new StandardAnalyzer(),
true, IndexWriter.MaxFieldLength.LIMITED);
>     writer.addDocument(doc);
>     writer.optimize();
>     writer.close();
>     // test again
>     s = new IndexSearcher("/opt/wwwroot/351/Index/test1");
>     h = s.search(q);
>     out.println("<P># of document found is now " + h.length());
>     r = IndexReader.open("/opt/wwwroot/351/Index/test1");
>     out.println("<P> max Doc is " + r.maxDoc());
> %>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Mime
View raw message