nomagick / paoding

Automatically exported from code.google.com/p/paoding
0 stars 0 forks source link

创建索引异常 #55

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
环境:paoding 2.0.4 beta,lucene 2.9.1

public static void createIndex(String str) {
        IndexWriter writer;
        try {
            Directory directory = new SimpleFSDirectory(new 
File(index),new SimpleFSLockFactory());  
            writer = new IndexWriter(directory, analyzer, 
true,IndexWriter.MaxFieldLength.UNLIMITED);
            Document doc = new Document();
            Field field = new Field("content", str, 
Field.Store.YES,
                Field.Index.ANALYZED, 
Field.TermVector.WITH_POSITIONS_OFFSETS);
            doc.add(field);
            System.out.println(writer);
            writer.addDocument(doc);
            //writer.close();
            System.out.println("Indexed success!");
        } catch (CorruptIndexException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (LockObtainFailedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }
上述创建索引方法失败。报异常如下:
java.lang.NullPointerException
    at org.apache.lucene.analysis.Tokenizer.close(Tokenizer.java:71)
    at org.apache.lucene.index.DocInverterPerField.processFields
(DocInverterPerField.java:197)
    at 
org.apache.lucene.index.DocFieldProcessorPerThread.processDocument
(DocFieldProcessorPerThread.java:244)
    at org.apache.lucene.index.DocumentsWriter.updateDocument
(DocumentsWriter.java:779)
    at org.apache.lucene.index.DocumentsWriter.addDocument
(DocumentsWriter.java:757)
    at org.apache.lucene.index.IndexWriter.addDocument
(IndexWriter.java:2472)
    at org.apache.lucene.index.IndexWriter.addDocument
(IndexWriter.java:2446)
    at com.sunppa.search.test.Test.createIndex(Test.java:37)
    at com.sunppa.search.test.Test.main(Test.java:70)

Original issue reported on code.google.com by shanchun...@gmail.com on 14 Jan 2010 at 10:01

GoogleCodeExporter commented 9 years ago
和solr整合查询的时候,也出现同样的异常
严重: java.lang.NullPointerException
        at org.apache.lucene.analysis.Tokenizer.close(Tokenizer.java:71)
        at org.apache.lucene.analysis.TokenFilter.close(TokenFilter.java:46)
        at org.apache.lucene.queryParser.QueryParser.getFieldQuery(QueryParser
ava:619)
        at org.apache.solr.search.SolrQueryParser.getFieldQuery(SolrQueryParse
java:153)
        at org.apache.lucene.queryParser.QueryParser.Term(QueryParser.java:144

        at org.apache.lucene.queryParser.QueryParser.Clause(QueryParser.java:1
7)
        at org.apache.lucene.queryParser.QueryParser.Query(QueryParser.java:12
)
        at org.apache.lucene.queryParser.QueryParser.TopLevelQuery(QueryParser
ava:1254)
        at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:20

        at org.apache.solr.search.LuceneQParser.parse(LuceneQParserPlugin.java
8)
        at org.apache.solr.search.QParser.getQuery(QParser.java:131)
        at org.apache.solr.handler.component.QueryComponent.prepare(QueryCompo
nt.java:89)
        at org.apache.solr.handler.component.SearchHandler.handleRequestBody(S
rchHandler.java:174)
        at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHan
erBase.java:131)
        at org.apache.solr.core.SolrCore.execute(SolrCore.java:1316)
        at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilt
.java:338)
        at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFil
r.java:241)

Original comment by shanchun...@gmail.com on 14 Jan 2010 at 11:42