You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by jianwen lou <lo...@gmail.com> on 2012/03/27 09:21:19 UTC

NumericField exception java.lang.IllegalStateException: call set???Value() before usage in lucene 3.5

I want to store the long type value to my index files like follwing:

                NumericField priceField = new NumericField("price");
                priceField.setDoubleValue(temp.getCurrentprice());
                document.add(priceField);

                NumericField salesField = new NumericField("salescount");
                priceField.setLongValue(temp.getSalescount());
                document.add(salesField);

                NumericField ontimefiled = new NumericField("ontime");
                ontimefiled.setLongValue(temp.getOntime().getTime());
                document.add(ontimefiled);

when writer add document i get the exception info:there is wrong with my
using NumbericField? thanks


java.lang.IllegalStateException: call set???Value() before usage
    at
org.apache.lucene.analysis.NumericTokenStream.reset(NumericTokenStream.java:196)
    at
org.apache.lucene.index.DocInverterPerField.processFields(DocInverterPerField.java:130)
    at
org.apache.lucene.index.DocFieldProcessorPerThread.processDocument(DocFieldProcessorPerThread.java:278)
    at
org.apache.lucene.index.DocumentsWriter.updateDocument(DocumentsWriter.java:766)
    at
org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:2066)
    at
com.beike.common.lucene.dao.IndexDaoImpl.saveGoodsIndex4Mobile(IndexDaoImpl.java:308)
    at
com.beike.common.lucene.dao.IndexStrategyServiceImpl.indexGoods4Mobile(IndexStrategyServiceImpl.java:118)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
    at
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
    at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
    at
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
    at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
    at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
    at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at
com.beike.ds.DataSourceInterceptor.invoke(DataSourceInterceptor.java:42)
    at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    at $Proxy53.indexGoods4Mobile(Unknown Source)
    at
com.beike.lucene.test.TestLuceneIndex.initGoodsIndex4Mobile(TestLuceneIndex.java:45)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at
org.springframework.test.context.junit4.SpringTestMethod.invoke(SpringTestMethod.java:160)
    at
org.springframework.test.context.junit4.SpringMethodRoadie.runTestMethod(SpringMethodRoadie.java:233)
    at
org.springframework.test.context.junit4.SpringMethodRoadie$RunBeforesThenTestThenAfters.run(SpringMethodRoadie.java:333)
    at
org.springframework.test.context.junit4.SpringMethodRoadie.runWithRepetitions(SpringMethodRoadie.java:217)
    at
org.springframework.test.context.junit4.SpringMethodRoadie.runTest(SpringMethodRoadie.java:197)
    at
org.springframework.test.context.junit4.SpringMethodRoadie.run(SpringMethodRoadie.java:143)
    at
org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:160)
    at
org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
    at
org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
    at
org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
    at
org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
    at
org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
    at
org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:97)
    at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
    at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)



-- 
*
*twitter.com/loujianwen

RE: TVD, TVX and TVF files

Posted by Luis Paiva <lu...@mail.telepac.pt>.
Sorry Mike, 

I pasted the old code. I've already included something like this to index
with TermVector: 

        String xpto = fr.toString();
        doc.add(new Field("contents2", xpto, 
                Field.Store.YES,
                Field.Index.ANALYZED,
                Field.TermVector.YES));
 
Probably my approach to my problem isn't the correct, so I explain better
what do i want. 

My idea is to have some files, like txt ones, and to get their each
TermVector for each file. I don't know if this can be done by simple
indexing the files. 

Thanks Mike. :)
Luis Paiva


-----Mensagem original-----
De: Michael McCandless [mailto:lucene@mikemccandless.com] 
Enviada: segunda-feira, 2 de Abril de 2012 20:49
Para: java-user@lucene.apache.org
Assunto: Re: TVD, TVX and TVF files

As far as I can see, you are not indexing term vectors in the code
below?  Your Fields don't have TermVector.*...

Can you boil this down to a small test case showing the missing term
vector files...?

Mike McCandless

http://blog.mikemccandless.com

On Mon, Apr 2, 2012 at 1:28 PM, Luis Paiva <lu...@mail.telepac.pt>
wrote:
> Thank you for your help.
> I still haven't found a solution yet. I'm copying all my code below.
>
> BTW, I'm working with lucene version 3.5.0
>
> @Mike: Yes i do close it :) I have some files created, that are: .fdt,
.fdx,
> .fnm, .frq, .nrm, .prx, .tii, .tis.
>
> Don't know why the files T* are not created.
>
> @Uwe: I think I'm not getting any compound files. Only those above.
>
> Anyone has the same issue?
>
>
>
> CODE --------------------------- xx -------------------------------
>
>
> package lucene;
>
> import java.io.*;
> import java.util.ArrayList;
> import org.apache.lucene.analysis.standard.StandardAnalyzer;
> import org.apache.lucene.document.Document;
> import org.apache.lucene.document.Field;
> import org.apache.lucene.index.IndexWriter;
> import org.apache.lucene.index.IndexWriterConfig;
> import org.apache.lucene.store.FSDirectory;
> import org.apache.lucene.util.Version;
>
> /**
>  * This terminal application creates an Apache Lucene index in a folder
and
> adds files into this index
>  * based on the input of the user.
>  */
> public class TextFileIndexer {
>
>  private IndexWriter writer;
>  private ArrayList<File> queue = new ArrayList<File>();
>
>  public static void main(String[] args) throws IOException {
>    System.out.println("Enter the path where the index will be created: ");
>
>    BufferedReader br = new BufferedReader(
>            new InputStreamReader(System.in));
>    String s = br.readLine();
>
>    TextFileIndexer indexer = null;
>    try {
>      indexer = new TextFileIndexer(s);
>    } catch (Exception ex) {
>      System.out.println("Cannot create index..." + ex.getMessage());
>      System.exit(-1);
>    }
>
>    //===================================================
>    //read input from user until he enters q for quit
>    //===================================================
>    while (!s.equalsIgnoreCase("q")) {
>      try {
>        System.out.println("Enter the file or folder name to add into the
> index (q=quit):");
>        System.out.println("[Acceptable file types: .xml, .html, .html,
> .txt]");
>        s = br.readLine();
>        if (s.equalsIgnoreCase("q")) {
>          break;
>        }
>
>        //try to add file into the index
>        indexer.indexFileOrDirectory(s);
>      } catch (Exception e) {
>        System.out.println("Error indexing " + s + " : " + e.getMessage());
>      }
>    }
>
>    //===================================================
>    //after adding, we always have to call the
>    //closeIndex, otherwise the index is not created
>    //===================================================
>    indexer.closeIndex();
>  }
>
>  /**
>   * Constructor
>   * @param indexDir the name of the folder in which the index should be
> created
>   * @throws java.io.IOException
>   */
>  TextFileIndexer(String indexDir) throws IOException {
>    // the boolean true parameter means to create a new index everytime,
>    // potentially overwriting any existing files there.
>    FSDirectory dir = FSDirectory.open(new File(indexDir));
>
>    StandardAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_34);
>
>    IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_34,
> analyzer);
>
>    writer = new IndexWriter(dir, config);
>  }
>
>  /**
>   * Indexes a file or directory
>   * @param fileName the name of a text file or a folder we wish to add to
> the index
>   * @throws java.io.IOException
>   */
>  public void indexFileOrDirectory(String fileName) throws IOException {
>    //===================================================
>    //gets the list of files in a folder (if user has submitted
>    //the name of a folder) or gets a single file name (is user
>    //has submitted only the file name)
>    //===================================================
>    addFiles(new File(fileName));
>
>    int originalNumDocs = writer.numDocs();
>    for (File f : queue) {
>      FileReader fr = null;
>      try {
>        Document doc = new Document();
>
>        //===================================================
>        // add contents of file
>        //===================================================
>        fr = new FileReader(f);
>        doc.add(new Field("contents", fr));
>
>
>
>        //===================================================
>        //adding second field which contains the path of the file
>        //===================================================
>        doc.add(new Field("path", fileName,
>                Field.Store.YES,
>                Field.Index.NOT_ANALYZED));
>
>        writer.addDocument(doc);
>        System.out.println("Added: " + f);
>      } catch (Exception e) {
>        System.out.println("Could not add: " + f);
>      } finally {
>        fr.close();
>      }
>    }
>
>    int newNumDocs = writer.numDocs();
>    System.out.println("");
>    System.out.println("************************");
>    System.out.println((newNumDocs - originalNumDocs) + " documents
> added.");
>    System.out.println("************************");
>
>    queue.clear();
>  }
>
>  private void addFiles(File file) {
>
>    if (!file.exists()) {
>      System.out.println(file + " does not exist.");
>    }
>    if (file.isDirectory()) {
>      for (File f : file.listFiles()) {
>        addFiles(f);
>      }
>    } else {
>      String filename = file.getName().toLowerCase();
>      //===================================================
>      // Only index text files
>      //===================================================
>      if (filename.endsWith(".htm") || filename.endsWith(".html") ||
>              filename.endsWith(".xml") || filename.endsWith(".txt")) {
>        queue.add(file);
>      } else {
>        System.out.println("Skipped " + filename);
>      }
>    }
>  }
>
>  /**
>   * Close the index.
>   * @throws java.io.IOException
>   */
>  public void closeIndex() throws IOException {
>    writer.close();
>  }
> }
>
> END OF CODE --------------------------- xx -------------------------------
>
>
> -----Mensagem original-----
> De: Uwe Schindler [mailto:uwe@thetaphi.de]
> Enviada: terça-feira, 27 de Março de 2012 19:19
> Para: java-user@lucene.apache.org
> Assunto: RE: TVD, TVX and TVF files
>
> Maybe you only see CFS files? If this is the case, your index is in
compound
> file format. In that case (the default), to get the raw files, disable
> compound files in the merge policy!
>
> -----
> Uwe Schindler
> H.-H.-Meier-Allee 63, D-28213 Bremen
> http://www.thetaphi.de
> eMail: uwe@thetaphi.de
>
>> -----Original Message-----
>> From: Michael McCandless [mailto:lucene@mikemccandless.com]
>> Sent: Tuesday, March 27, 2012 8:13 PM
>> To: java-user@lucene.apache.org
>> Subject: Re: TVD, TVX and TVF files
>>
>> The code seems OK on quick glance...
>>
>> Are you closing the writer?
>>
>> Are you hitting any exceptions?
>>
>> Mike McCandless
>>
>> http://blog.mikemccandless.com
>>
>> On Tue, Mar 27, 2012 at 12:19 PM, Luis Paiva <lu...@mail.telepac.pt>
>> wrote:
>> > Hey all,
>> >
>> > i'm in my first steps in Lucene.
>> > I was trying to index some txt files, and my program doesn't construct
>> > the term vector files. I would need these files. (.tvd, .tvx, .tvf)
>> >
>> > I'm attaching my code so anyone can help me.
>> > Thank you all in advance!
>> >
>> > Sorry if i'm repeating the question, but i couldn't find the answer to
> it.
>> >
>> >
>> > public void indexFileOrDirectory(String fileName) throws IOException {
>> >
>> >    addFiles(new File(fileName));
>> >
>> >    int originalNumDocs = writer.numDocs();
>> >    for (File f : queue) {
>> >      FileReader fr = null;
>> >      try {
>> >        Document doc = new Document();
>> >
>> >        fr = new FileReader(f);
>> >        doc.add(new Field("contents", fr));
>> >
>> >        doc.add(new Field("path", fileName, Field.Store.YES,
>> > Field.Index.NOT_ANALYZED));
>> >
>> >        String xpto = "xpto1 xpto2 xpto3";
>> >        doc.add(new Field("contents2", xpto, Field.Store.YES,
>> > Field.Index.ANALYZED, Field.TermVector.YES));
>> >
>> >        writer.addDocument(doc);
>> >        System.out.println("Added: " + f);
>> >      } catch (Exception e) {
>> >        System.out.println("Could not add: " + f);
>> >      } finally {
>> >        fr.close();
>> >      }
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> > For additional commands, e-mail: java-user-help@lucene.apache.org
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>

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


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


Re: TVD, TVX and TVF files

Posted by Michael McCandless <lu...@mikemccandless.com>.
As far as I can see, you are not indexing term vectors in the code
below?  Your Fields don't have TermVector.*...

Can you boil this down to a small test case showing the missing term
vector files...?

Mike McCandless

http://blog.mikemccandless.com

On Mon, Apr 2, 2012 at 1:28 PM, Luis Paiva <lu...@mail.telepac.pt> wrote:
> Thank you for your help.
> I still haven't found a solution yet. I'm copying all my code below.
>
> BTW, I'm working with lucene version 3.5.0
>
> @Mike: Yes i do close it :) I have some files created, that are: .fdt, .fdx,
> .fnm, .frq, .nrm, .prx, .tii, .tis.
>
> Don't know why the files T* are not created.
>
> @Uwe: I think I'm not getting any compound files. Only those above.
>
> Anyone has the same issue?
>
>
>
> CODE --------------------------- xx -------------------------------
>
>
> package lucene;
>
> import java.io.*;
> import java.util.ArrayList;
> import org.apache.lucene.analysis.standard.StandardAnalyzer;
> import org.apache.lucene.document.Document;
> import org.apache.lucene.document.Field;
> import org.apache.lucene.index.IndexWriter;
> import org.apache.lucene.index.IndexWriterConfig;
> import org.apache.lucene.store.FSDirectory;
> import org.apache.lucene.util.Version;
>
> /**
>  * This terminal application creates an Apache Lucene index in a folder and
> adds files into this index
>  * based on the input of the user.
>  */
> public class TextFileIndexer {
>
>  private IndexWriter writer;
>  private ArrayList<File> queue = new ArrayList<File>();
>
>  public static void main(String[] args) throws IOException {
>    System.out.println("Enter the path where the index will be created: ");
>
>    BufferedReader br = new BufferedReader(
>            new InputStreamReader(System.in));
>    String s = br.readLine();
>
>    TextFileIndexer indexer = null;
>    try {
>      indexer = new TextFileIndexer(s);
>    } catch (Exception ex) {
>      System.out.println("Cannot create index..." + ex.getMessage());
>      System.exit(-1);
>    }
>
>    //===================================================
>    //read input from user until he enters q for quit
>    //===================================================
>    while (!s.equalsIgnoreCase("q")) {
>      try {
>        System.out.println("Enter the file or folder name to add into the
> index (q=quit):");
>        System.out.println("[Acceptable file types: .xml, .html, .html,
> .txt]");
>        s = br.readLine();
>        if (s.equalsIgnoreCase("q")) {
>          break;
>        }
>
>        //try to add file into the index
>        indexer.indexFileOrDirectory(s);
>      } catch (Exception e) {
>        System.out.println("Error indexing " + s + " : " + e.getMessage());
>      }
>    }
>
>    //===================================================
>    //after adding, we always have to call the
>    //closeIndex, otherwise the index is not created
>    //===================================================
>    indexer.closeIndex();
>  }
>
>  /**
>   * Constructor
>   * @param indexDir the name of the folder in which the index should be
> created
>   * @throws java.io.IOException
>   */
>  TextFileIndexer(String indexDir) throws IOException {
>    // the boolean true parameter means to create a new index everytime,
>    // potentially overwriting any existing files there.
>    FSDirectory dir = FSDirectory.open(new File(indexDir));
>
>    StandardAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_34);
>
>    IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_34,
> analyzer);
>
>    writer = new IndexWriter(dir, config);
>  }
>
>  /**
>   * Indexes a file or directory
>   * @param fileName the name of a text file or a folder we wish to add to
> the index
>   * @throws java.io.IOException
>   */
>  public void indexFileOrDirectory(String fileName) throws IOException {
>    //===================================================
>    //gets the list of files in a folder (if user has submitted
>    //the name of a folder) or gets a single file name (is user
>    //has submitted only the file name)
>    //===================================================
>    addFiles(new File(fileName));
>
>    int originalNumDocs = writer.numDocs();
>    for (File f : queue) {
>      FileReader fr = null;
>      try {
>        Document doc = new Document();
>
>        //===================================================
>        // add contents of file
>        //===================================================
>        fr = new FileReader(f);
>        doc.add(new Field("contents", fr));
>
>
>
>        //===================================================
>        //adding second field which contains the path of the file
>        //===================================================
>        doc.add(new Field("path", fileName,
>                Field.Store.YES,
>                Field.Index.NOT_ANALYZED));
>
>        writer.addDocument(doc);
>        System.out.println("Added: " + f);
>      } catch (Exception e) {
>        System.out.println("Could not add: " + f);
>      } finally {
>        fr.close();
>      }
>    }
>
>    int newNumDocs = writer.numDocs();
>    System.out.println("");
>    System.out.println("************************");
>    System.out.println((newNumDocs - originalNumDocs) + " documents
> added.");
>    System.out.println("************************");
>
>    queue.clear();
>  }
>
>  private void addFiles(File file) {
>
>    if (!file.exists()) {
>      System.out.println(file + " does not exist.");
>    }
>    if (file.isDirectory()) {
>      for (File f : file.listFiles()) {
>        addFiles(f);
>      }
>    } else {
>      String filename = file.getName().toLowerCase();
>      //===================================================
>      // Only index text files
>      //===================================================
>      if (filename.endsWith(".htm") || filename.endsWith(".html") ||
>              filename.endsWith(".xml") || filename.endsWith(".txt")) {
>        queue.add(file);
>      } else {
>        System.out.println("Skipped " + filename);
>      }
>    }
>  }
>
>  /**
>   * Close the index.
>   * @throws java.io.IOException
>   */
>  public void closeIndex() throws IOException {
>    writer.close();
>  }
> }
>
> END OF CODE --------------------------- xx -------------------------------
>
>
> -----Mensagem original-----
> De: Uwe Schindler [mailto:uwe@thetaphi.de]
> Enviada: terça-feira, 27 de Março de 2012 19:19
> Para: java-user@lucene.apache.org
> Assunto: RE: TVD, TVX and TVF files
>
> Maybe you only see CFS files? If this is the case, your index is in compound
> file format. In that case (the default), to get the raw files, disable
> compound files in the merge policy!
>
> -----
> Uwe Schindler
> H.-H.-Meier-Allee 63, D-28213 Bremen
> http://www.thetaphi.de
> eMail: uwe@thetaphi.de
>
>> -----Original Message-----
>> From: Michael McCandless [mailto:lucene@mikemccandless.com]
>> Sent: Tuesday, March 27, 2012 8:13 PM
>> To: java-user@lucene.apache.org
>> Subject: Re: TVD, TVX and TVF files
>>
>> The code seems OK on quick glance...
>>
>> Are you closing the writer?
>>
>> Are you hitting any exceptions?
>>
>> Mike McCandless
>>
>> http://blog.mikemccandless.com
>>
>> On Tue, Mar 27, 2012 at 12:19 PM, Luis Paiva <lu...@mail.telepac.pt>
>> wrote:
>> > Hey all,
>> >
>> > i'm in my first steps in Lucene.
>> > I was trying to index some txt files, and my program doesn't construct
>> > the term vector files. I would need these files. (.tvd, .tvx, .tvf)
>> >
>> > I'm attaching my code so anyone can help me.
>> > Thank you all in advance!
>> >
>> > Sorry if i'm repeating the question, but i couldn't find the answer to
> it.
>> >
>> >
>> > public void indexFileOrDirectory(String fileName) throws IOException {
>> >
>> >    addFiles(new File(fileName));
>> >
>> >    int originalNumDocs = writer.numDocs();
>> >    for (File f : queue) {
>> >      FileReader fr = null;
>> >      try {
>> >        Document doc = new Document();
>> >
>> >        fr = new FileReader(f);
>> >        doc.add(new Field("contents", fr));
>> >
>> >        doc.add(new Field("path", fileName, Field.Store.YES,
>> > Field.Index.NOT_ANALYZED));
>> >
>> >        String xpto = "xpto1 xpto2 xpto3";
>> >        doc.add(new Field("contents2", xpto, Field.Store.YES,
>> > Field.Index.ANALYZED, Field.TermVector.YES));
>> >
>> >        writer.addDocument(doc);
>> >        System.out.println("Added: " + f);
>> >      } catch (Exception e) {
>> >        System.out.println("Could not add: " + f);
>> >      } finally {
>> >        fr.close();
>> >      }
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> > For additional commands, e-mail: java-user-help@lucene.apache.org
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>

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


RE: TVD, TVX and TVF files

Posted by Luis Paiva <lu...@mail.telepac.pt>.
Thank you for your help. 
I still haven't found a solution yet. I'm copying all my code below. 

BTW, I'm working with lucene version 3.5.0

@Mike: Yes i do close it :) I have some files created, that are: .fdt, .fdx,
.fnm, .frq, .nrm, .prx, .tii, .tis.

Don't know why the files T* are not created. 

@Uwe: I think I'm not getting any compound files. Only those above. 

Anyone has the same issue? 



CODE --------------------------- xx -------------------------------


package lucene;

import java.io.*;
import java.util.ArrayList;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.util.Version;

/**
 * This terminal application creates an Apache Lucene index in a folder and
adds files into this index
 * based on the input of the user.
 */
public class TextFileIndexer {

  private IndexWriter writer;
  private ArrayList<File> queue = new ArrayList<File>();

  public static void main(String[] args) throws IOException {
    System.out.println("Enter the path where the index will be created: ");

    BufferedReader br = new BufferedReader(
            new InputStreamReader(System.in));
    String s = br.readLine();

    TextFileIndexer indexer = null;
    try {
      indexer = new TextFileIndexer(s);
    } catch (Exception ex) {
      System.out.println("Cannot create index..." + ex.getMessage());
      System.exit(-1);
    }

    //===================================================
    //read input from user until he enters q for quit
    //===================================================
    while (!s.equalsIgnoreCase("q")) {
      try {
        System.out.println("Enter the file or folder name to add into the
index (q=quit):");
        System.out.println("[Acceptable file types: .xml, .html, .html,
.txt]");
        s = br.readLine();
        if (s.equalsIgnoreCase("q")) {
          break;
        }

        //try to add file into the index
        indexer.indexFileOrDirectory(s);
      } catch (Exception e) {
        System.out.println("Error indexing " + s + " : " + e.getMessage());
      }
    }

    //===================================================
    //after adding, we always have to call the
    //closeIndex, otherwise the index is not created    
    //===================================================
    indexer.closeIndex();
  }

  /**
   * Constructor
   * @param indexDir the name of the folder in which the index should be
created
   * @throws java.io.IOException
   */
  TextFileIndexer(String indexDir) throws IOException {
    // the boolean true parameter means to create a new index everytime, 
    // potentially overwriting any existing files there.
    FSDirectory dir = FSDirectory.open(new File(indexDir));

    StandardAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_34);

    IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_34,
analyzer);

    writer = new IndexWriter(dir, config);
  }

  /**
   * Indexes a file or directory
   * @param fileName the name of a text file or a folder we wish to add to
the index
   * @throws java.io.IOException
   */
  public void indexFileOrDirectory(String fileName) throws IOException {
    //===================================================
    //gets the list of files in a folder (if user has submitted
    //the name of a folder) or gets a single file name (is user
    //has submitted only the file name) 
    //===================================================
    addFiles(new File(fileName));
    
    int originalNumDocs = writer.numDocs();
    for (File f : queue) {
      FileReader fr = null;
      try {
        Document doc = new Document();

        //===================================================
        // add contents of file
        //===================================================
        fr = new FileReader(f);
        doc.add(new Field("contents", fr));
        
        

        //===================================================
        //adding second field which contains the path of the file
        //===================================================
        doc.add(new Field("path", fileName,
                Field.Store.YES,
                Field.Index.NOT_ANALYZED));

        writer.addDocument(doc);
        System.out.println("Added: " + f);
      } catch (Exception e) {
        System.out.println("Could not add: " + f);
      } finally {
        fr.close();
      }
    }
    
    int newNumDocs = writer.numDocs();
    System.out.println("");
    System.out.println("************************");
    System.out.println((newNumDocs - originalNumDocs) + " documents
added.");
    System.out.println("************************");

    queue.clear();
  }

  private void addFiles(File file) {

    if (!file.exists()) {
      System.out.println(file + " does not exist.");
    }
    if (file.isDirectory()) {
      for (File f : file.listFiles()) {
        addFiles(f);
      }
    } else {
      String filename = file.getName().toLowerCase();
      //===================================================
      // Only index text files
      //===================================================
      if (filename.endsWith(".htm") || filename.endsWith(".html") || 
              filename.endsWith(".xml") || filename.endsWith(".txt")) {
        queue.add(file);
      } else {
        System.out.println("Skipped " + filename);
      }
    }
  }

  /**
   * Close the index.
   * @throws java.io.IOException
   */
  public void closeIndex() throws IOException {
    writer.close();
  }
}

END OF CODE --------------------------- xx -------------------------------


-----Mensagem original-----
De: Uwe Schindler [mailto:uwe@thetaphi.de] 
Enviada: terça-feira, 27 de Março de 2012 19:19
Para: java-user@lucene.apache.org
Assunto: RE: TVD, TVX and TVF files

Maybe you only see CFS files? If this is the case, your index is in compound
file format. In that case (the default), to get the raw files, disable
compound files in the merge policy!

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de

> -----Original Message-----
> From: Michael McCandless [mailto:lucene@mikemccandless.com]
> Sent: Tuesday, March 27, 2012 8:13 PM
> To: java-user@lucene.apache.org
> Subject: Re: TVD, TVX and TVF files
> 
> The code seems OK on quick glance...
> 
> Are you closing the writer?
> 
> Are you hitting any exceptions?
> 
> Mike McCandless
> 
> http://blog.mikemccandless.com
> 
> On Tue, Mar 27, 2012 at 12:19 PM, Luis Paiva <lu...@mail.telepac.pt>
> wrote:
> > Hey all,
> >
> > i'm in my first steps in Lucene.
> > I was trying to index some txt files, and my program doesn't construct
> > the term vector files. I would need these files. (.tvd, .tvx, .tvf)
> >
> > I'm attaching my code so anyone can help me.
> > Thank you all in advance!
> >
> > Sorry if i'm repeating the question, but i couldn't find the answer to
it.
> >
> >
> > public void indexFileOrDirectory(String fileName) throws IOException {
> >
> >    addFiles(new File(fileName));
> >
> >    int originalNumDocs = writer.numDocs();
> >    for (File f : queue) {
> >      FileReader fr = null;
> >      try {
> >        Document doc = new Document();
> >
> >        fr = new FileReader(f);
> >        doc.add(new Field("contents", fr));
> >
> >        doc.add(new Field("path", fileName, Field.Store.YES,
> > Field.Index.NOT_ANALYZED));
> >
> >        String xpto = "xpto1 xpto2 xpto3";
> >        doc.add(new Field("contents2", xpto, Field.Store.YES,
> > Field.Index.ANALYZED, Field.TermVector.YES));
> >
> >        writer.addDocument(doc);
> >        System.out.println("Added: " + f);
> >      } catch (Exception e) {
> >        System.out.println("Could not add: " + f);
> >      } finally {
> >        fr.close();
> >      }
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > For additional commands, e-mail: java-user-help@lucene.apache.org
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org


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


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


RE: TVD, TVX and TVF files

Posted by Uwe Schindler <uw...@thetaphi.de>.
Maybe you only see CFS files? If this is the case, your index is in compound
file format. In that case (the default), to get the raw files, disable
compound files in the merge policy!

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de

> -----Original Message-----
> From: Michael McCandless [mailto:lucene@mikemccandless.com]
> Sent: Tuesday, March 27, 2012 8:13 PM
> To: java-user@lucene.apache.org
> Subject: Re: TVD, TVX and TVF files
> 
> The code seems OK on quick glance...
> 
> Are you closing the writer?
> 
> Are you hitting any exceptions?
> 
> Mike McCandless
> 
> http://blog.mikemccandless.com
> 
> On Tue, Mar 27, 2012 at 12:19 PM, Luis Paiva <lu...@mail.telepac.pt>
> wrote:
> > Hey all,
> >
> > i'm in my first steps in Lucene.
> > I was trying to index some txt files, and my program doesn't construct
> > the term vector files. I would need these files. (.tvd, .tvx, .tvf)
> >
> > I'm attaching my code so anyone can help me.
> > Thank you all in advance!
> >
> > Sorry if i'm repeating the question, but i couldn't find the answer to
it.
> >
> >
> > public void indexFileOrDirectory(String fileName) throws IOException {
> >
> >    addFiles(new File(fileName));
> >
> >    int originalNumDocs = writer.numDocs();
> >    for (File f : queue) {
> >      FileReader fr = null;
> >      try {
> >        Document doc = new Document();
> >
> >        fr = new FileReader(f);
> >        doc.add(new Field("contents", fr));
> >
> >        doc.add(new Field("path", fileName, Field.Store.YES,
> > Field.Index.NOT_ANALYZED));
> >
> >        String xpto = "xpto1 xpto2 xpto3";
> >        doc.add(new Field("contents2", xpto, Field.Store.YES,
> > Field.Index.ANALYZED, Field.TermVector.YES));
> >
> >        writer.addDocument(doc);
> >        System.out.println("Added: " + f);
> >      } catch (Exception e) {
> >        System.out.println("Could not add: " + f);
> >      } finally {
> >        fr.close();
> >      }
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > For additional commands, e-mail: java-user-help@lucene.apache.org
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org


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


Re: TVD, TVX and TVF files

Posted by Michael McCandless <lu...@mikemccandless.com>.
The code seems OK on quick glance...

Are you closing the writer?

Are you hitting any exceptions?

Mike McCandless

http://blog.mikemccandless.com

On Tue, Mar 27, 2012 at 12:19 PM, Luis Paiva <lu...@mail.telepac.pt> wrote:
> Hey all,
>
> i'm in my first steps in Lucene.
> I was trying to index some txt files, and my program doesn't construct the
> term vector files. I would need these files. (.tvd, .tvx, .tvf)
>
> I'm attaching my code so anyone can help me.
> Thank you all in advance!
>
> Sorry if i'm repeating the question, but i couldn't find the answer to it.
>
>
> public void indexFileOrDirectory(String fileName) throws IOException {
>
>    addFiles(new File(fileName));
>
>    int originalNumDocs = writer.numDocs();
>    for (File f : queue) {
>      FileReader fr = null;
>      try {
>        Document doc = new Document();
>
>        fr = new FileReader(f);
>        doc.add(new Field("contents", fr));
>
>        doc.add(new Field("path", fileName, Field.Store.YES,
> Field.Index.NOT_ANALYZED));
>
>        String xpto = "xpto1 xpto2 xpto3";
>        doc.add(new Field("contents2", xpto, Field.Store.YES,
> Field.Index.ANALYZED, Field.TermVector.YES));
>
>        writer.addDocument(doc);
>        System.out.println("Added: " + f);
>      } catch (Exception e) {
>        System.out.println("Could not add: " + f);
>      } finally {
>        fr.close();
>      }
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>

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


TVD, TVX and TVF files

Posted by Luis Paiva <lu...@mail.telepac.pt>.
Hey all, 

i'm in my first steps in Lucene. 
I was trying to index some txt files, and my program doesn't construct the
term vector files. I would need these files. (.tvd, .tvx, .tvf)

I'm attaching my code so anyone can help me. 
Thank you all in advance! 

Sorry if i'm repeating the question, but i couldn't find the answer to it.


public void indexFileOrDirectory(String fileName) throws IOException {

    addFiles(new File(fileName));
    
    int originalNumDocs = writer.numDocs();
    for (File f : queue) {
      FileReader fr = null;
      try {
        Document doc = new Document();
        
        fr = new FileReader(f);
        doc.add(new Field("contents", fr));

        doc.add(new Field("path", fileName, Field.Store.YES,
Field.Index.NOT_ANALYZED));

        String xpto = "xpto1 xpto2 xpto3";
        doc.add(new Field("contents2", xpto, Field.Store.YES,
Field.Index.ANALYZED, Field.TermVector.YES));

        writer.addDocument(doc);
        System.out.println("Added: " + f);
      } catch (Exception e) {
        System.out.println("Could not add: " + f);
      } finally {
        fr.close();
      }


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


Re: NumericField exception java.lang.IllegalStateException: call set???Value() before usage in lucene 3.5

Posted by Erick Erickson <er...@gmail.com>.
I'll, of course, defer to Uwe for technical Lucene issues, but you've
got a copy/paste error it looks like. I doubt it's the root of your
problem, but this code reuses priceField, it seems like
you intend the second to use salesField....

    NumericField priceField = new NumericField("price");
    priceField.setDoubleValue(temp.getCurrentprice())
    document.add(priceField);

    NumericField salesField = new NumericField("salescount");
    priceField.setLongValue(temp.getSalescount());
    document.add(salesField);


On Tue, Mar 27, 2012 at 6:09 AM, jianwen lou <lo...@gmail.com> wrote:
> It seems that the Analyzer i used in my project is the problem.I use
> CJKAnalyzer,I am not exactly understand the lucene analysis and tokenizer
> process .Is there other way to do this:
> I want to store numbers and date time in the lucene filed and to use the
> filed to filter and range the search,thanks
>
> On Tue, Mar 27, 2012 at 5:31 PM, Uwe Schindler <uw...@thetaphi.de> wrote:
>
>> The bug mentioned in this link was a multithread bug (what I asked you). If
>> you reuse Documents and Fields this can happen, otherwise not. This code is
>> heavily tested and the code you sent cannot fail. Maybe its different to
>> the
>> one you actually use?
>>
>> -----
>> Uwe Schindler
>> H.-H.-Meier-Allee 63, D-28213 Bremen
>> http://www.thetaphi.de
>> eMail: uwe@thetaphi.de
>>
>>
>> > -----Original Message-----
>> > From: jianwen lou [mailto:loujanwen@gmail.com]
>> > Sent: Tuesday, March 27, 2012 9:49 AM
>> > To: java-user@lucene.apache.org
>> > Subject: Re: NumericField exception java.lang.IllegalStateException: call
>> > set???Value() before usage in lucene 3.5
>> >
>> > No,There is no multi-thread building index at same time, I google and get
>> the
>> > result, i use 64 bit jvm. It matters?
>> >
>> >
>>
>> http://lucene.472066.n3.nabble.com/Lucene-3-4-shift-bug-in-possibly-invalid-
>> > use-of-NumericTokenStream-td3592962.html
>> >
>> > F:\Java\open-source\lucene>java -version java version "1.6.0_25"
>> > Java(TM) SE Runtime Environment (build 1.6.0_25-b06) Java HotSpot(TM) 64-
>> > Bit Server VM (build 20.0-b11, mixed mode)
>> >
>> >
>> > On Tue, Mar 27, 2012 at 3:24 PM, Uwe Schindler <uw...@thetaphi.de> wrote:
>> >
>> > > Hi,
>> > >
>> > > Are you sure that you are not reusing the same NumericField instances
>> > > across different threads?
>> > >
>> > > -----
>> > > Uwe Schindler
>> > > H.-H.-Meier-Allee 63, D-28213 Bremen
>> > > http://www.thetaphi.de
>> > > eMail: uwe@thetaphi.de
>> > >
>> > >
>> > > > -----Original Message-----
>> > > > From: jianwen lou [mailto:loujanwen@gmail.com]
>> > > > Sent: Tuesday, March 27, 2012 9:21 AM
>> > > > To: java-user@lucene.apache.org
>> > > > Subject: NumericField exception java.lang.IllegalStateException:
>> > > > call
>> > > > set???Value() before usage in lucene 3.5
>> > > >
>> > > > I want to store the long type value to my index files like follwing:
>> > > >
>> > > >                 NumericField priceField = new NumericField("price");
>> > > >                 priceField.setDoubleValue(temp.getCurrentprice());
>> > > >                 document.add(priceField);
>> > > >
>> > > >                 NumericField salesField = new
>> NumericField("salescount");
>> > > >                 priceField.setLongValue(temp.getSalescount());
>> > > >                 document.add(salesField);
>> > > >
>> > > >                 NumericField ontimefiled = new
>> NumericField("ontime");
>> > > >                 ontimefiled.setLongValue(temp.getOntime().getTime());
>> > > >                 document.add(ontimefiled);
>> > > >
>> > > > when writer add document i get the exception info:there is wrong
>> > > > with my using NumbericField? thanks
>> > > >
>> > > >
>> > > > java.lang.IllegalStateException: call set???Value() before usage
>> > > >     at
>> > > > org.apache.lucene.analysis.NumericTokenStream.reset(NumericTokenStre
>> > > > am.j
>> > > > ava:196)
>> > > >     at
>> > > >
>> > >
>> > > org.apache.lucene.index.DocInverterPerField.processFields(DocInverterP
>> > > erFiel
>> > > d
>> > > > .java:130)
>> > > >     at
>> > > > org.apache.lucene.index.DocFieldProcessorPerThread.processDocument(D
>> > > > ocFie
>> > > > ldProcessorPerThread.java:278)
>> > > >     at
>> > > >
>> > org.apache.lucene.index.DocumentsWriter.updateDocument(DocumentsWrit
>> > > > er
>> > > > .java:766)
>> > > >     at
>> > > >
>> org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:2066)
>> > > >     at
>> > > >
>> > com.beike.common.lucene.dao.IndexDaoImpl.saveGoodsIndex4Mobile(Index
>> > > > Da
>> > > > oImpl.java:308)
>> > > >     at
>> > > > com.beike.common.lucene.dao.IndexStrategyServiceImpl.indexGoods4Mobi
>> > > > le(I
>> > > > ndexStrategyServiceImpl.java:118)
>> > > >     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> > > >     at
>> > > >
>> > >
>> >
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
>> > > > 39)
>> > > >     at
>> > > > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcce
>> > > > ssorI
>> > > > mpl.java:25)
>> > > >     at java.lang.reflect.Method.invoke(Method.java:597)
>> > > >     at
>> > > >
>> > > org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflectio
>> > > n(Aop
>> > > > Utils.java:307)
>> > > >     at
>> > > > org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJ
>> > > > oinpo
>> > > > int(ReflectiveMethodInvocation.java:182)
>> > > >     at
>> > > > org.springframework.aop.framework.ReflectiveMethodInvocation.proceed
>> > > > (Refl
>> > > > ectiveMethodInvocation.java:149)
>> > > >     at
>> > > >
>> > >
>> > > org.springframework.transaction.interceptor.TransactionInterceptor.inv
>> > > oke(Tr
>> > > a
>> > > > nsactionInterceptor.java:106)
>> > > >     at
>> > > > org.springframework.aop.framework.ReflectiveMethodInvocation.proceed
>> > > > (Refl
>> > > > ectiveMethodInvocation.java:171)
>> > > >     at
>> > > >
>> > >
>> > > org.springframework.transaction.interceptor.TransactionInterceptor.inv
>> > > oke(Tr
>> > > a
>> > > > nsactionInterceptor.java:106)
>> > > >     at
>> > > > org.springframework.aop.framework.ReflectiveMethodInvocation.proceed
>> > > > (Refl
>> > > > ectiveMethodInvocation.java:171)
>> > > >     at
>> > > >
>> > >
>> > > org.springframework.transaction.interceptor.TransactionInterceptor.inv
>> > > oke(Tr
>> > > a
>> > > > nsactionInterceptor.java:106)
>> > > >     at
>> > > > org.springframework.aop.framework.ReflectiveMethodInvocation.proceed
>> > > > (Refl
>> > > > ectiveMethodInvocation.java:171)
>> > > >     at
>> > > >
>> com.beike.ds.DataSourceInterceptor.invoke(DataSourceInterceptor.java:42)
>> > > >     at
>> > > > org.springframework.aop.framework.ReflectiveMethodInvocation.proceed
>> > > > (Refl
>> > > > ectiveMethodInvocation.java:171)
>> > > >     at
>> > > >
>> > org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynam
>> > > > ic
>> > > > AopProxy.java:204)
>> > > >     at $Proxy53.indexGoods4Mobile(Unknown Source)
>> > > >     at
>> > > >
>> > > com.beike.lucene.test.TestLuceneIndex.initGoodsIndex4Mobile(TestLucene
>> > > Inde
>> > > > x.java:45)
>> > > >     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> > > >     at
>> > > >
>> > >
>> >
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
>> > > > 39)
>> > > >     at
>> > > > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcce
>> > > > ssorI
>> > > > mpl.java:25)
>> > > >     at java.lang.reflect.Method.invoke(Method.java:597)
>> > > >     at
>> > > >
>> > > org.springframework.test.context.junit4.SpringTestMethod.invoke(Spring
>> > > TestM
>> > > > ethod.java:160)
>> > > >     at
>> > > >
>> > > org.springframework.test.context.junit4.SpringMethodRoadie.runTestMeth
>> > > od(S
>> > > > pringMethodRoadie.java:233)
>> > > >     at
>> > > > org.springframework.test.context.junit4.SpringMethodRoadie$RunBefore
>> > > > sThen
>> > > > TestThenAfters.run(SpringMethodRoadie.java:333)
>> > > >     at
>> > > >
>> > > org.springframework.test.context.junit4.SpringMethodRoadie.runWithRepe
>> > > titio
>> > > > ns(SpringMethodRoadie.java:217)
>> > > >     at
>> > > >
>> > > org.springframework.test.context.junit4.SpringMethodRoadie.runTest(Spr
>> > > ingM
>> > > > ethodRoadie.java:197)
>> > > >     at
>> > > >
>> > > org.springframework.test.context.junit4.SpringMethodRoadie.run(SpringM
>> > > etho
>> > > > dRoadie.java:143)
>> > > >     at
>> > > >
>> > >
>> > > org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invoke
>> > > TestMe
>> > > > thod(SpringJUnit4ClassRunner.java:160)
>> > > >     at
>> > > >
>> > >
>> > > org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRun
>> > > ner.ja
>> > > v
>> > > > a:51)
>> > > >     at
>> > > >
>> > >
>> > > org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.j
>> > > ava:44
>> > > )
>> > > >     at
>> > > >
>> > > org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java
>> > > :27)
>> > > >     at
>> > > >
>> org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
>> > > >     at
>> > > >
>> > > org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.jav
>> > > a:42)
>> > > >     at
>> > > >
>> > >
>> > > org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(Sp
>> > > ringJU
>> > > n
>> > > > it4ClassRunner.java:97)
>> > > >     at
>> > > >
>> > >
>> > > org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4T
>> > > estRef
>> > > ere
>> > > > nce.java:38)
>> > > >     at
>> > > >
>> > >
>> > > org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.
>> > > java:3
>> > > 8)
>> > > >     at
>> > > >
>> > >
>> > > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remote
>> > > TestRu
>> > > > nner.java:460)
>> > > >     at
>> > > >
>> > >
>> > > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remote
>> > > TestRu
>> > > > nner.java:673)
>> > > >     at
>> > > >
>> > >
>> > >
>> >
>>
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.
>> > > > java:386)
>> > > >     at
>> > > >
>> > > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTest
>> > > Runne
>> > > > r.java:196)
>> > > >
>> > > >
>> > > >
>> > > > --
>> > > > *
>> > > > *twitter.com/loujianwen
>> > >
>> > >
>> > > ---------------------------------------------------------------------
>> > > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> > > For additional commands, e-mail: java-user-help@lucene.apache.org
>> > >
>> > >
>> >
>> >
>> > --
>> > *
>> > *twitter.com/loujianwen
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>
>>
>
>
> --
> *
> *twitter.com/loujianwen

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


Re: NumericField exception java.lang.IllegalStateException: call set???Value() before usage in lucene 3.5

Posted by jianwen lou <lo...@gmail.com>.
It seems that the Analyzer i used in my project is the problem.I use
CJKAnalyzer,I am not exactly understand the lucene analysis and tokenizer
process .Is there other way to do this:
I want to store numbers and date time in the lucene filed and to use the
filed to filter and range the search,thanks

On Tue, Mar 27, 2012 at 5:31 PM, Uwe Schindler <uw...@thetaphi.de> wrote:

> The bug mentioned in this link was a multithread bug (what I asked you). If
> you reuse Documents and Fields this can happen, otherwise not. This code is
> heavily tested and the code you sent cannot fail. Maybe its different to
> the
> one you actually use?
>
> -----
> Uwe Schindler
> H.-H.-Meier-Allee 63, D-28213 Bremen
> http://www.thetaphi.de
> eMail: uwe@thetaphi.de
>
>
> > -----Original Message-----
> > From: jianwen lou [mailto:loujanwen@gmail.com]
> > Sent: Tuesday, March 27, 2012 9:49 AM
> > To: java-user@lucene.apache.org
> > Subject: Re: NumericField exception java.lang.IllegalStateException: call
> > set???Value() before usage in lucene 3.5
> >
> > No,There is no multi-thread building index at same time, I google and get
> the
> > result, i use 64 bit jvm. It matters?
> >
> >
>
> http://lucene.472066.n3.nabble.com/Lucene-3-4-shift-bug-in-possibly-invalid-
> > use-of-NumericTokenStream-td3592962.html
> >
> > F:\Java\open-source\lucene>java -version java version "1.6.0_25"
> > Java(TM) SE Runtime Environment (build 1.6.0_25-b06) Java HotSpot(TM) 64-
> > Bit Server VM (build 20.0-b11, mixed mode)
> >
> >
> > On Tue, Mar 27, 2012 at 3:24 PM, Uwe Schindler <uw...@thetaphi.de> wrote:
> >
> > > Hi,
> > >
> > > Are you sure that you are not reusing the same NumericField instances
> > > across different threads?
> > >
> > > -----
> > > Uwe Schindler
> > > H.-H.-Meier-Allee 63, D-28213 Bremen
> > > http://www.thetaphi.de
> > > eMail: uwe@thetaphi.de
> > >
> > >
> > > > -----Original Message-----
> > > > From: jianwen lou [mailto:loujanwen@gmail.com]
> > > > Sent: Tuesday, March 27, 2012 9:21 AM
> > > > To: java-user@lucene.apache.org
> > > > Subject: NumericField exception java.lang.IllegalStateException:
> > > > call
> > > > set???Value() before usage in lucene 3.5
> > > >
> > > > I want to store the long type value to my index files like follwing:
> > > >
> > > >                 NumericField priceField = new NumericField("price");
> > > >                 priceField.setDoubleValue(temp.getCurrentprice());
> > > >                 document.add(priceField);
> > > >
> > > >                 NumericField salesField = new
> NumericField("salescount");
> > > >                 priceField.setLongValue(temp.getSalescount());
> > > >                 document.add(salesField);
> > > >
> > > >                 NumericField ontimefiled = new
> NumericField("ontime");
> > > >                 ontimefiled.setLongValue(temp.getOntime().getTime());
> > > >                 document.add(ontimefiled);
> > > >
> > > > when writer add document i get the exception info:there is wrong
> > > > with my using NumbericField? thanks
> > > >
> > > >
> > > > java.lang.IllegalStateException: call set???Value() before usage
> > > >     at
> > > > org.apache.lucene.analysis.NumericTokenStream.reset(NumericTokenStre
> > > > am.j
> > > > ava:196)
> > > >     at
> > > >
> > >
> > > org.apache.lucene.index.DocInverterPerField.processFields(DocInverterP
> > > erFiel
> > > d
> > > > .java:130)
> > > >     at
> > > > org.apache.lucene.index.DocFieldProcessorPerThread.processDocument(D
> > > > ocFie
> > > > ldProcessorPerThread.java:278)
> > > >     at
> > > >
> > org.apache.lucene.index.DocumentsWriter.updateDocument(DocumentsWrit
> > > > er
> > > > .java:766)
> > > >     at
> > > >
> org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:2066)
> > > >     at
> > > >
> > com.beike.common.lucene.dao.IndexDaoImpl.saveGoodsIndex4Mobile(Index
> > > > Da
> > > > oImpl.java:308)
> > > >     at
> > > > com.beike.common.lucene.dao.IndexStrategyServiceImpl.indexGoods4Mobi
> > > > le(I
> > > > ndexStrategyServiceImpl.java:118)
> > > >     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > > >     at
> > > >
> > >
> >
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
> > > > 39)
> > > >     at
> > > > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcce
> > > > ssorI
> > > > mpl.java:25)
> > > >     at java.lang.reflect.Method.invoke(Method.java:597)
> > > >     at
> > > >
> > > org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflectio
> > > n(Aop
> > > > Utils.java:307)
> > > >     at
> > > > org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJ
> > > > oinpo
> > > > int(ReflectiveMethodInvocation.java:182)
> > > >     at
> > > > org.springframework.aop.framework.ReflectiveMethodInvocation.proceed
> > > > (Refl
> > > > ectiveMethodInvocation.java:149)
> > > >     at
> > > >
> > >
> > > org.springframework.transaction.interceptor.TransactionInterceptor.inv
> > > oke(Tr
> > > a
> > > > nsactionInterceptor.java:106)
> > > >     at
> > > > org.springframework.aop.framework.ReflectiveMethodInvocation.proceed
> > > > (Refl
> > > > ectiveMethodInvocation.java:171)
> > > >     at
> > > >
> > >
> > > org.springframework.transaction.interceptor.TransactionInterceptor.inv
> > > oke(Tr
> > > a
> > > > nsactionInterceptor.java:106)
> > > >     at
> > > > org.springframework.aop.framework.ReflectiveMethodInvocation.proceed
> > > > (Refl
> > > > ectiveMethodInvocation.java:171)
> > > >     at
> > > >
> > >
> > > org.springframework.transaction.interceptor.TransactionInterceptor.inv
> > > oke(Tr
> > > a
> > > > nsactionInterceptor.java:106)
> > > >     at
> > > > org.springframework.aop.framework.ReflectiveMethodInvocation.proceed
> > > > (Refl
> > > > ectiveMethodInvocation.java:171)
> > > >     at
> > > >
> com.beike.ds.DataSourceInterceptor.invoke(DataSourceInterceptor.java:42)
> > > >     at
> > > > org.springframework.aop.framework.ReflectiveMethodInvocation.proceed
> > > > (Refl
> > > > ectiveMethodInvocation.java:171)
> > > >     at
> > > >
> > org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynam
> > > > ic
> > > > AopProxy.java:204)
> > > >     at $Proxy53.indexGoods4Mobile(Unknown Source)
> > > >     at
> > > >
> > > com.beike.lucene.test.TestLuceneIndex.initGoodsIndex4Mobile(TestLucene
> > > Inde
> > > > x.java:45)
> > > >     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > > >     at
> > > >
> > >
> >
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
> > > > 39)
> > > >     at
> > > > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcce
> > > > ssorI
> > > > mpl.java:25)
> > > >     at java.lang.reflect.Method.invoke(Method.java:597)
> > > >     at
> > > >
> > > org.springframework.test.context.junit4.SpringTestMethod.invoke(Spring
> > > TestM
> > > > ethod.java:160)
> > > >     at
> > > >
> > > org.springframework.test.context.junit4.SpringMethodRoadie.runTestMeth
> > > od(S
> > > > pringMethodRoadie.java:233)
> > > >     at
> > > > org.springframework.test.context.junit4.SpringMethodRoadie$RunBefore
> > > > sThen
> > > > TestThenAfters.run(SpringMethodRoadie.java:333)
> > > >     at
> > > >
> > > org.springframework.test.context.junit4.SpringMethodRoadie.runWithRepe
> > > titio
> > > > ns(SpringMethodRoadie.java:217)
> > > >     at
> > > >
> > > org.springframework.test.context.junit4.SpringMethodRoadie.runTest(Spr
> > > ingM
> > > > ethodRoadie.java:197)
> > > >     at
> > > >
> > > org.springframework.test.context.junit4.SpringMethodRoadie.run(SpringM
> > > etho
> > > > dRoadie.java:143)
> > > >     at
> > > >
> > >
> > > org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invoke
> > > TestMe
> > > > thod(SpringJUnit4ClassRunner.java:160)
> > > >     at
> > > >
> > >
> > > org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRun
> > > ner.ja
> > > v
> > > > a:51)
> > > >     at
> > > >
> > >
> > > org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.j
> > > ava:44
> > > )
> > > >     at
> > > >
> > > org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java
> > > :27)
> > > >     at
> > > >
> org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
> > > >     at
> > > >
> > > org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.jav
> > > a:42)
> > > >     at
> > > >
> > >
> > > org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(Sp
> > > ringJU
> > > n
> > > > it4ClassRunner.java:97)
> > > >     at
> > > >
> > >
> > > org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4T
> > > estRef
> > > ere
> > > > nce.java:38)
> > > >     at
> > > >
> > >
> > > org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.
> > > java:3
> > > 8)
> > > >     at
> > > >
> > >
> > > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remote
> > > TestRu
> > > > nner.java:460)
> > > >     at
> > > >
> > >
> > > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remote
> > > TestRu
> > > > nner.java:673)
> > > >     at
> > > >
> > >
> > >
> >
>
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.
> > > > java:386)
> > > >     at
> > > >
> > > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTest
> > > Runne
> > > > r.java:196)
> > > >
> > > >
> > > >
> > > > --
> > > > *
> > > > *twitter.com/loujianwen
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > > For additional commands, e-mail: java-user-help@lucene.apache.org
> > >
> > >
> >
> >
> > --
> > *
> > *twitter.com/loujianwen
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>


-- 
*
*twitter.com/loujianwen

RE: NumericField exception java.lang.IllegalStateException: call set???Value() before usage in lucene 3.5

Posted by Uwe Schindler <uw...@thetaphi.de>.
The bug mentioned in this link was a multithread bug (what I asked you). If
you reuse Documents and Fields this can happen, otherwise not. This code is
heavily tested and the code you sent cannot fail. Maybe its different to the
one you actually use?

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de


> -----Original Message-----
> From: jianwen lou [mailto:loujanwen@gmail.com]
> Sent: Tuesday, March 27, 2012 9:49 AM
> To: java-user@lucene.apache.org
> Subject: Re: NumericField exception java.lang.IllegalStateException: call
> set???Value() before usage in lucene 3.5
> 
> No,There is no multi-thread building index at same time, I google and get
the
> result, i use 64 bit jvm. It matters?
> 
>
http://lucene.472066.n3.nabble.com/Lucene-3-4-shift-bug-in-possibly-invalid-
> use-of-NumericTokenStream-td3592962.html
> 
> F:\Java\open-source\lucene>java -version java version "1.6.0_25"
> Java(TM) SE Runtime Environment (build 1.6.0_25-b06) Java HotSpot(TM) 64-
> Bit Server VM (build 20.0-b11, mixed mode)
> 
> 
> On Tue, Mar 27, 2012 at 3:24 PM, Uwe Schindler <uw...@thetaphi.de> wrote:
> 
> > Hi,
> >
> > Are you sure that you are not reusing the same NumericField instances
> > across different threads?
> >
> > -----
> > Uwe Schindler
> > H.-H.-Meier-Allee 63, D-28213 Bremen
> > http://www.thetaphi.de
> > eMail: uwe@thetaphi.de
> >
> >
> > > -----Original Message-----
> > > From: jianwen lou [mailto:loujanwen@gmail.com]
> > > Sent: Tuesday, March 27, 2012 9:21 AM
> > > To: java-user@lucene.apache.org
> > > Subject: NumericField exception java.lang.IllegalStateException:
> > > call
> > > set???Value() before usage in lucene 3.5
> > >
> > > I want to store the long type value to my index files like follwing:
> > >
> > >                 NumericField priceField = new NumericField("price");
> > >                 priceField.setDoubleValue(temp.getCurrentprice());
> > >                 document.add(priceField);
> > >
> > >                 NumericField salesField = new
NumericField("salescount");
> > >                 priceField.setLongValue(temp.getSalescount());
> > >                 document.add(salesField);
> > >
> > >                 NumericField ontimefiled = new NumericField("ontime");
> > >                 ontimefiled.setLongValue(temp.getOntime().getTime());
> > >                 document.add(ontimefiled);
> > >
> > > when writer add document i get the exception info:there is wrong
> > > with my using NumbericField? thanks
> > >
> > >
> > > java.lang.IllegalStateException: call set???Value() before usage
> > >     at
> > > org.apache.lucene.analysis.NumericTokenStream.reset(NumericTokenStre
> > > am.j
> > > ava:196)
> > >     at
> > >
> >
> > org.apache.lucene.index.DocInverterPerField.processFields(DocInverterP
> > erFiel
> > d
> > > .java:130)
> > >     at
> > > org.apache.lucene.index.DocFieldProcessorPerThread.processDocument(D
> > > ocFie
> > > ldProcessorPerThread.java:278)
> > >     at
> > >
> org.apache.lucene.index.DocumentsWriter.updateDocument(DocumentsWrit
> > > er
> > > .java:766)
> > >     at
> > > org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:2066)
> > >     at
> > >
> com.beike.common.lucene.dao.IndexDaoImpl.saveGoodsIndex4Mobile(Index
> > > Da
> > > oImpl.java:308)
> > >     at
> > > com.beike.common.lucene.dao.IndexStrategyServiceImpl.indexGoods4Mobi
> > > le(I
> > > ndexStrategyServiceImpl.java:118)
> > >     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > >     at
> > >
> >
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
> > > 39)
> > >     at
> > > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcce
> > > ssorI
> > > mpl.java:25)
> > >     at java.lang.reflect.Method.invoke(Method.java:597)
> > >     at
> > >
> > org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflectio
> > n(Aop
> > > Utils.java:307)
> > >     at
> > > org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJ
> > > oinpo
> > > int(ReflectiveMethodInvocation.java:182)
> > >     at
> > > org.springframework.aop.framework.ReflectiveMethodInvocation.proceed
> > > (Refl
> > > ectiveMethodInvocation.java:149)
> > >     at
> > >
> >
> > org.springframework.transaction.interceptor.TransactionInterceptor.inv
> > oke(Tr
> > a
> > > nsactionInterceptor.java:106)
> > >     at
> > > org.springframework.aop.framework.ReflectiveMethodInvocation.proceed
> > > (Refl
> > > ectiveMethodInvocation.java:171)
> > >     at
> > >
> >
> > org.springframework.transaction.interceptor.TransactionInterceptor.inv
> > oke(Tr
> > a
> > > nsactionInterceptor.java:106)
> > >     at
> > > org.springframework.aop.framework.ReflectiveMethodInvocation.proceed
> > > (Refl
> > > ectiveMethodInvocation.java:171)
> > >     at
> > >
> >
> > org.springframework.transaction.interceptor.TransactionInterceptor.inv
> > oke(Tr
> > a
> > > nsactionInterceptor.java:106)
> > >     at
> > > org.springframework.aop.framework.ReflectiveMethodInvocation.proceed
> > > (Refl
> > > ectiveMethodInvocation.java:171)
> > >     at
> > >
com.beike.ds.DataSourceInterceptor.invoke(DataSourceInterceptor.java:42)
> > >     at
> > > org.springframework.aop.framework.ReflectiveMethodInvocation.proceed
> > > (Refl
> > > ectiveMethodInvocation.java:171)
> > >     at
> > >
> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynam
> > > ic
> > > AopProxy.java:204)
> > >     at $Proxy53.indexGoods4Mobile(Unknown Source)
> > >     at
> > >
> > com.beike.lucene.test.TestLuceneIndex.initGoodsIndex4Mobile(TestLucene
> > Inde
> > > x.java:45)
> > >     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > >     at
> > >
> >
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
> > > 39)
> > >     at
> > > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcce
> > > ssorI
> > > mpl.java:25)
> > >     at java.lang.reflect.Method.invoke(Method.java:597)
> > >     at
> > >
> > org.springframework.test.context.junit4.SpringTestMethod.invoke(Spring
> > TestM
> > > ethod.java:160)
> > >     at
> > >
> > org.springframework.test.context.junit4.SpringMethodRoadie.runTestMeth
> > od(S
> > > pringMethodRoadie.java:233)
> > >     at
> > > org.springframework.test.context.junit4.SpringMethodRoadie$RunBefore
> > > sThen
> > > TestThenAfters.run(SpringMethodRoadie.java:333)
> > >     at
> > >
> > org.springframework.test.context.junit4.SpringMethodRoadie.runWithRepe
> > titio
> > > ns(SpringMethodRoadie.java:217)
> > >     at
> > >
> > org.springframework.test.context.junit4.SpringMethodRoadie.runTest(Spr
> > ingM
> > > ethodRoadie.java:197)
> > >     at
> > >
> > org.springframework.test.context.junit4.SpringMethodRoadie.run(SpringM
> > etho
> > > dRoadie.java:143)
> > >     at
> > >
> >
> > org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invoke
> > TestMe
> > > thod(SpringJUnit4ClassRunner.java:160)
> > >     at
> > >
> >
> > org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRun
> > ner.ja
> > v
> > > a:51)
> > >     at
> > >
> >
> > org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.j
> > ava:44
> > )
> > >     at
> > >
> > org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java
> > :27)
> > >     at
> > >
org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
> > >     at
> > >
> > org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.jav
> > a:42)
> > >     at
> > >
> >
> > org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(Sp
> > ringJU
> > n
> > > it4ClassRunner.java:97)
> > >     at
> > >
> >
> > org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4T
> > estRef
> > ere
> > > nce.java:38)
> > >     at
> > >
> >
> > org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.
> > java:3
> > 8)
> > >     at
> > >
> >
> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remote
> > TestRu
> > > nner.java:460)
> > >     at
> > >
> >
> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remote
> > TestRu
> > > nner.java:673)
> > >     at
> > >
> >
> >
>
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.
> > > java:386)
> > >     at
> > >
> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTest
> > Runne
> > > r.java:196)
> > >
> > >
> > >
> > > --
> > > *
> > > *twitter.com/loujianwen
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > For additional commands, e-mail: java-user-help@lucene.apache.org
> >
> >
> 
> 
> --
> *
> *twitter.com/loujianwen


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


RE: NumericField exception java.lang.IllegalStateException: call set???Value() before usage in lucene 3.5

Posted by Uwe Schindler <uw...@thetaphi.de>.
Hi,

> I am not exactly understand the precisionStep arg,I need to add  the arg?

RTFM: http://goo.gl/PlhhO

> On Tue, Mar 27, 2012 at 3:48 PM, jianwen lou <lo...@gmail.com> wrote:
> 
> > No,There is no multi-thread building index at same time, I google and
> > get the result, i use 64 bit jvm. It matters?
> >
> >
> > http://lucene.472066.n3.nabble.com/Lucene-3-4-shift-bug-in-possibly-in
> > valid-use-of-NumericTokenStream-td3592962.html
> >
> > F:\Java\open-source\lucene>java -version java version "1.6.0_25"
> > Java(TM) SE Runtime Environment (build 1.6.0_25-b06) Java HotSpot(TM)
> > 64-Bit Server VM (build 20.0-b11, mixed mode)
> >
> >
> >
> > On Tue, Mar 27, 2012 at 3:24 PM, Uwe Schindler <uw...@thetaphi.de> wrote:
> >
> >> Hi,
> >>
> >> Are you sure that you are not reusing the same NumericField instances
> >> across different threads?
> >>
> >> -----
> >> Uwe Schindler
> >> H.-H.-Meier-Allee 63, D-28213 Bremen
> >> http://www.thetaphi.de
> >> eMail: uwe@thetaphi.de
> >>
> >>
> >> > -----Original Message-----
> >> > From: jianwen lou [mailto:loujanwen@gmail.com]
> >> > Sent: Tuesday, March 27, 2012 9:21 AM
> >> > To: java-user@lucene.apache.org
> >> > Subject: NumericField exception java.lang.IllegalStateException:
> >> > call
> >> > set???Value() before usage in lucene 3.5
> >> >
> >> > I want to store the long type value to my index files like follwing:
> >> >
> >> >                 NumericField priceField = new NumericField("price");
> >> >                 priceField.setDoubleValue(temp.getCurrentprice());
> >> >                 document.add(priceField);
> >> >
> >> >                 NumericField salesField = new
> >> NumericField("salescount");
> >> >                 priceField.setLongValue(temp.getSalescount());
> >> >                 document.add(salesField);
> >> >
> >> >                 NumericField ontimefiled = new
NumericField("ontime");
> >> >                 ontimefiled.setLongValue(temp.getOntime().getTime());
> >> >                 document.add(ontimefiled);
> >> >
> >> > when writer add document i get the exception info:there is wrong
> >> > with my using NumbericField? thanks
> >> >
> >> >
> >> > java.lang.IllegalStateException: call set???Value() before usage
> >> >     at
> >> > org.apache.lucene.analysis.NumericTokenStream.reset(NumericTokenStr
> >> > eam.j
> >> > ava:196)
> >> >     at
> >> >
> >>
> >> org.apache.lucene.index.DocInverterPerField.processFields(DocInverter
> >> PerFiel
> >> d
> >> > .java:130)
> >> >     at
> >> >
> >> org.apache.lucene.index.DocFieldProcessorPerThread.processDocument(Do
> >> cFie
> >> > ldProcessorPerThread.java:278)
> >> >     at
> >> >
> org.apache.lucene.index.DocumentsWriter.updateDocument(DocumentsWri
> >> > ter
> >> > .java:766)
> >> >     at
> >> >
> org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:2066)
> >> >     at
> >> >
> com.beike.common.lucene.dao.IndexDaoImpl.saveGoodsIndex4Mobile(Inde
> >> > xDa
> >> > oImpl.java:308)
> >> >     at
> >> >
> com.beike.common.lucene.dao.IndexStrategyServiceImpl.indexGoods4Mob
> >> > ile(I
> >> > ndexStrategyServiceImpl.java:118)
> >> >     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >> >     at
> >> >
> >>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
> >> > 39)
> >> >     at
> >> >
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
> >> sorI
> >> > mpl.java:25)
> >> >     at java.lang.reflect.Method.invoke(Method.java:597)
> >> >     at
> >> >
> >>
> >> org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflecti
> >> on(Aop
> >> > Utils.java:307)
> >> >     at
> >> >
> >> org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJo
> >> inpo
> >> > int(ReflectiveMethodInvocation.java:182)
> >> >     at
> >> >
> >> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
> >> Refl
> >> > ectiveMethodInvocation.java:149)
> >> >     at
> >> >
> >>
> >> org.springframework.transaction.interceptor.TransactionInterceptor.in
> >> voke(Tr
> >> a
> >> > nsactionInterceptor.java:106)
> >> >     at
> >> >
> >> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
> >> Refl
> >> > ectiveMethodInvocation.java:171)
> >> >     at
> >> >
> >>
> >> org.springframework.transaction.interceptor.TransactionInterceptor.in
> >> voke(Tr
> >> a
> >> > nsactionInterceptor.java:106)
> >> >     at
> >> >
> >> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
> >> Refl
> >> > ectiveMethodInvocation.java:171)
> >> >     at
> >> >
> >>
> >> org.springframework.transaction.interceptor.TransactionInterceptor.in
> >> voke(Tr
> >> a
> >> > nsactionInterceptor.java:106)
> >> >     at
> >> >
> >> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
> >> Refl
> >> > ectiveMethodInvocation.java:171)
> >> >     at
> >> >
> com.beike.ds.DataSourceInterceptor.invoke(DataSourceInterceptor.java:42)
> >> >     at
> >> >
> >> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
> >> Refl
> >> > ectiveMethodInvocation.java:171)
> >> >     at
> >> >
> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDyna
> >> > mic
> >> > AopProxy.java:204)
> >> >     at $Proxy53.indexGoods4Mobile(Unknown Source)
> >> >     at
> >> >
> >> com.beike.lucene.test.TestLuceneIndex.initGoodsIndex4Mobile(TestLucen
> >> eInde
> >> > x.java:45)
> >> >     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >> >     at
> >> >
> >>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
> >> > 39)
> >> >     at
> >> >
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
> >> sorI
> >> > mpl.java:25)
> >> >     at java.lang.reflect.Method.invoke(Method.java:597)
> >> >     at
> >> >
> >>
> >> org.springframework.test.context.junit4.SpringTestMethod.invoke(Sprin
> >> gTestM
> >> > ethod.java:160)
> >> >     at
> >> >
> >> org.springframework.test.context.junit4.SpringMethodRoadie.runTestMet
> >> hod(S
> >> > pringMethodRoadie.java:233)
> >> >     at
> >> >
> >> org.springframework.test.context.junit4.SpringMethodRoadie$RunBefores
> >> Then
> >> > TestThenAfters.run(SpringMethodRoadie.java:333)
> >> >     at
> >> >
> >>
> >> org.springframework.test.context.junit4.SpringMethodRoadie.runWithRep
> >> etitio
> >> > ns(SpringMethodRoadie.java:217)
> >> >     at
> >> >
> >> org.springframework.test.context.junit4.SpringMethodRoadie.runTest(Sp
> >> ringM
> >> > ethodRoadie.java:197)
> >> >     at
> >> >
> >> org.springframework.test.context.junit4.SpringMethodRoadie.run(Spring
> >> Metho
> >> > dRoadie.java:143)
> >> >     at
> >> >
> >>
> >> org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invok
> >> eTestMe
> >> > thod(SpringJUnit4ClassRunner.java:160)
> >> >     at
> >> >
> >>
> >> org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRu
> >> nner.ja
> >> v
> >> > a:51)
> >> >     at
> >> >
> >>
> >> org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.
> >> java:44
> >> )
> >> >     at
> >> >
> >> org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.jav
> >> a:27)
> >> >     at
> >> >
org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
> >> >     at
> >> >
> >>
> >> org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.ja
> >> va:42)
> >> >     at
> >> >
> >>
> >> org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(S
> >> pringJU
> >> n
> >> > it4ClassRunner.java:97)
> >> >     at
> >> >
> >>
> >> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4
> >> TestRef
> >> ere
> >> > nce.java:38)
> >> >     at
> >> >
> >>
> >> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution
> >> .java:3
> >> 8)
> >> >     at
> >> >
> >>
> >> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remot
> >> eTestRu
> >> > nner.java:460)
> >> >     at
> >> >
> >>
> >> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remot
> >> eTestRu
> >> > nner.java:673)
> >> >     at
> >> >
> >>
> >>
>
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.
> >> > java:386)
> >> >     at
> >> >
> >>
> >> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTes
> >> tRunne
> >> > r.java:196)
> >> >
> >> >
> >> >
> >> > --
> >> > *
> >> > *twitter.com/loujianwen
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> >> For additional commands, e-mail: java-user-help@lucene.apache.org
> >>
> >>
> >
> >
> > --
> > *
> > *twitter.com/loujianwen
> >
> >
> 
> 
> --
> *
> *twitter.com/loujianwen


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


Re: NumericField exception java.lang.IllegalStateException: call set???Value() before usage in lucene 3.5

Posted by jianwen lou <lo...@gmail.com>.
I am not exactly understand the precisionStep arg,I need to add  the arg?

On Tue, Mar 27, 2012 at 3:48 PM, jianwen lou <lo...@gmail.com> wrote:

> No,There is no multi-thread building index at same time,
> I google and get the result, i use 64 bit jvm. It matters?
>
>
> http://lucene.472066.n3.nabble.com/Lucene-3-4-shift-bug-in-possibly-invalid-use-of-NumericTokenStream-td3592962.html
>
> F:\Java\open-source\lucene>java -version
> java version "1.6.0_25"
> Java(TM) SE Runtime Environment (build 1.6.0_25-b06)
> Java HotSpot(TM) 64-Bit Server VM (build 20.0-b11, mixed mode)
>
>
>
> On Tue, Mar 27, 2012 at 3:24 PM, Uwe Schindler <uw...@thetaphi.de> wrote:
>
>> Hi,
>>
>> Are you sure that you are not reusing the same NumericField instances
>> across
>> different threads?
>>
>> -----
>> Uwe Schindler
>> H.-H.-Meier-Allee 63, D-28213 Bremen
>> http://www.thetaphi.de
>> eMail: uwe@thetaphi.de
>>
>>
>> > -----Original Message-----
>> > From: jianwen lou [mailto:loujanwen@gmail.com]
>> > Sent: Tuesday, March 27, 2012 9:21 AM
>> > To: java-user@lucene.apache.org
>> > Subject: NumericField exception java.lang.IllegalStateException: call
>> > set???Value() before usage in lucene 3.5
>> >
>> > I want to store the long type value to my index files like follwing:
>> >
>> >                 NumericField priceField = new NumericField("price");
>> >                 priceField.setDoubleValue(temp.getCurrentprice());
>> >                 document.add(priceField);
>> >
>> >                 NumericField salesField = new
>> NumericField("salescount");
>> >                 priceField.setLongValue(temp.getSalescount());
>> >                 document.add(salesField);
>> >
>> >                 NumericField ontimefiled = new NumericField("ontime");
>> >                 ontimefiled.setLongValue(temp.getOntime().getTime());
>> >                 document.add(ontimefiled);
>> >
>> > when writer add document i get the exception info:there is wrong with my
>> > using NumbericField? thanks
>> >
>> >
>> > java.lang.IllegalStateException: call set???Value() before usage
>> >     at
>> > org.apache.lucene.analysis.NumericTokenStream.reset(NumericTokenStream.j
>> > ava:196)
>> >     at
>> >
>>
>> org.apache.lucene.index.DocInverterPerField.processFields(DocInverterPerFiel
>> d
>> > .java:130)
>> >     at
>> >
>> org.apache.lucene.index.DocFieldProcessorPerThread.processDocument(DocFie
>> > ldProcessorPerThread.java:278)
>> >     at
>> > org.apache.lucene.index.DocumentsWriter.updateDocument(DocumentsWriter
>> > .java:766)
>> >     at
>> > org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:2066)
>> >     at
>> > com.beike.common.lucene.dao.IndexDaoImpl.saveGoodsIndex4Mobile(IndexDa
>> > oImpl.java:308)
>> >     at
>> > com.beike.common.lucene.dao.IndexStrategyServiceImpl.indexGoods4Mobile(I
>> > ndexStrategyServiceImpl.java:118)
>> >     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> >     at
>> >
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
>> > 39)
>> >     at
>> >
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorI
>> > mpl.java:25)
>> >     at java.lang.reflect.Method.invoke(Method.java:597)
>> >     at
>> >
>>
>> org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(Aop
>> > Utils.java:307)
>> >     at
>> >
>> org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpo
>> > int(ReflectiveMethodInvocation.java:182)
>> >     at
>> >
>> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(Refl
>> > ectiveMethodInvocation.java:149)
>> >     at
>> >
>>
>> org.springframework.transaction.interceptor.TransactionInterceptor.invoke(Tr
>> a
>> > nsactionInterceptor.java:106)
>> >     at
>> >
>> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(Refl
>> > ectiveMethodInvocation.java:171)
>> >     at
>> >
>>
>> org.springframework.transaction.interceptor.TransactionInterceptor.invoke(Tr
>> a
>> > nsactionInterceptor.java:106)
>> >     at
>> >
>> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(Refl
>> > ectiveMethodInvocation.java:171)
>> >     at
>> >
>>
>> org.springframework.transaction.interceptor.TransactionInterceptor.invoke(Tr
>> a
>> > nsactionInterceptor.java:106)
>> >     at
>> >
>> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(Refl
>> > ectiveMethodInvocation.java:171)
>> >     at
>> > com.beike.ds.DataSourceInterceptor.invoke(DataSourceInterceptor.java:42)
>> >     at
>> >
>> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(Refl
>> > ectiveMethodInvocation.java:171)
>> >     at
>> > org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamic
>> > AopProxy.java:204)
>> >     at $Proxy53.indexGoods4Mobile(Unknown Source)
>> >     at
>> >
>> com.beike.lucene.test.TestLuceneIndex.initGoodsIndex4Mobile(TestLuceneInde
>> > x.java:45)
>> >     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> >     at
>> >
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
>> > 39)
>> >     at
>> >
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorI
>> > mpl.java:25)
>> >     at java.lang.reflect.Method.invoke(Method.java:597)
>> >     at
>> >
>>
>> org.springframework.test.context.junit4.SpringTestMethod.invoke(SpringTestM
>> > ethod.java:160)
>> >     at
>> >
>> org.springframework.test.context.junit4.SpringMethodRoadie.runTestMethod(S
>> > pringMethodRoadie.java:233)
>> >     at
>> >
>> org.springframework.test.context.junit4.SpringMethodRoadie$RunBeforesThen
>> > TestThenAfters.run(SpringMethodRoadie.java:333)
>> >     at
>> >
>>
>> org.springframework.test.context.junit4.SpringMethodRoadie.runWithRepetitio
>> > ns(SpringMethodRoadie.java:217)
>> >     at
>> >
>> org.springframework.test.context.junit4.SpringMethodRoadie.runTest(SpringM
>> > ethodRoadie.java:197)
>> >     at
>> >
>> org.springframework.test.context.junit4.SpringMethodRoadie.run(SpringMetho
>> > dRoadie.java:143)
>> >     at
>> >
>>
>> org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMe
>> > thod(SpringJUnit4ClassRunner.java:160)
>> >     at
>> >
>>
>> org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.ja
>> v
>> > a:51)
>> >     at
>> >
>>
>> org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44
>> )
>> >     at
>> >
>> org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
>> >     at
>> > org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
>> >     at
>> >
>>
>> org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
>> >     at
>> >
>>
>> org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJU
>> n
>> > it4ClassRunner.java:97)
>> >     at
>> >
>>
>> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestRef
>> ere
>> > nce.java:38)
>> >     at
>> >
>>
>> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:3
>> 8)
>> >     at
>> >
>>
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRu
>> > nner.java:460)
>> >     at
>> >
>>
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRu
>> > nner.java:673)
>> >     at
>> >
>>
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.
>> > java:386)
>> >     at
>> >
>>
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunne
>> > r.java:196)
>> >
>> >
>> >
>> > --
>> > *
>> > *twitter.com/loujianwen
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>
>>
>
>
> --
> *
> *twitter.com/loujianwen
>
>


-- 
*
*twitter.com/loujianwen

Re: NumericField exception java.lang.IllegalStateException: call set???Value() before usage in lucene 3.5

Posted by jianwen lou <lo...@gmail.com>.
No,There is no multi-thread building index at same time,
I google and get the result, i use 64 bit jvm. It matters?

http://lucene.472066.n3.nabble.com/Lucene-3-4-shift-bug-in-possibly-invalid-use-of-NumericTokenStream-td3592962.html

F:\Java\open-source\lucene>java -version
java version "1.6.0_25"
Java(TM) SE Runtime Environment (build 1.6.0_25-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.0-b11, mixed mode)


On Tue, Mar 27, 2012 at 3:24 PM, Uwe Schindler <uw...@thetaphi.de> wrote:

> Hi,
>
> Are you sure that you are not reusing the same NumericField instances
> across
> different threads?
>
> -----
> Uwe Schindler
> H.-H.-Meier-Allee 63, D-28213 Bremen
> http://www.thetaphi.de
> eMail: uwe@thetaphi.de
>
>
> > -----Original Message-----
> > From: jianwen lou [mailto:loujanwen@gmail.com]
> > Sent: Tuesday, March 27, 2012 9:21 AM
> > To: java-user@lucene.apache.org
> > Subject: NumericField exception java.lang.IllegalStateException: call
> > set???Value() before usage in lucene 3.5
> >
> > I want to store the long type value to my index files like follwing:
> >
> >                 NumericField priceField = new NumericField("price");
> >                 priceField.setDoubleValue(temp.getCurrentprice());
> >                 document.add(priceField);
> >
> >                 NumericField salesField = new NumericField("salescount");
> >                 priceField.setLongValue(temp.getSalescount());
> >                 document.add(salesField);
> >
> >                 NumericField ontimefiled = new NumericField("ontime");
> >                 ontimefiled.setLongValue(temp.getOntime().getTime());
> >                 document.add(ontimefiled);
> >
> > when writer add document i get the exception info:there is wrong with my
> > using NumbericField? thanks
> >
> >
> > java.lang.IllegalStateException: call set???Value() before usage
> >     at
> > org.apache.lucene.analysis.NumericTokenStream.reset(NumericTokenStream.j
> > ava:196)
> >     at
> >
>
> org.apache.lucene.index.DocInverterPerField.processFields(DocInverterPerFiel
> d
> > .java:130)
> >     at
> > org.apache.lucene.index.DocFieldProcessorPerThread.processDocument(DocFie
> > ldProcessorPerThread.java:278)
> >     at
> > org.apache.lucene.index.DocumentsWriter.updateDocument(DocumentsWriter
> > .java:766)
> >     at
> > org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:2066)
> >     at
> > com.beike.common.lucene.dao.IndexDaoImpl.saveGoodsIndex4Mobile(IndexDa
> > oImpl.java:308)
> >     at
> > com.beike.common.lucene.dao.IndexStrategyServiceImpl.indexGoods4Mobile(I
> > ndexStrategyServiceImpl.java:118)
> >     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >     at
> >
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
> > 39)
> >     at
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorI
> > mpl.java:25)
> >     at java.lang.reflect.Method.invoke(Method.java:597)
> >     at
> >
> org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(Aop
> > Utils.java:307)
> >     at
> > org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpo
> > int(ReflectiveMethodInvocation.java:182)
> >     at
> > org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(Refl
> > ectiveMethodInvocation.java:149)
> >     at
> >
>
> org.springframework.transaction.interceptor.TransactionInterceptor.invoke(Tr
> a
> > nsactionInterceptor.java:106)
> >     at
> > org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(Refl
> > ectiveMethodInvocation.java:171)
> >     at
> >
>
> org.springframework.transaction.interceptor.TransactionInterceptor.invoke(Tr
> a
> > nsactionInterceptor.java:106)
> >     at
> > org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(Refl
> > ectiveMethodInvocation.java:171)
> >     at
> >
>
> org.springframework.transaction.interceptor.TransactionInterceptor.invoke(Tr
> a
> > nsactionInterceptor.java:106)
> >     at
> > org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(Refl
> > ectiveMethodInvocation.java:171)
> >     at
> > com.beike.ds.DataSourceInterceptor.invoke(DataSourceInterceptor.java:42)
> >     at
> > org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(Refl
> > ectiveMethodInvocation.java:171)
> >     at
> > org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamic
> > AopProxy.java:204)
> >     at $Proxy53.indexGoods4Mobile(Unknown Source)
> >     at
> >
> com.beike.lucene.test.TestLuceneIndex.initGoodsIndex4Mobile(TestLuceneInde
> > x.java:45)
> >     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >     at
> >
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
> > 39)
> >     at
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorI
> > mpl.java:25)
> >     at java.lang.reflect.Method.invoke(Method.java:597)
> >     at
> >
> org.springframework.test.context.junit4.SpringTestMethod.invoke(SpringTestM
> > ethod.java:160)
> >     at
> >
> org.springframework.test.context.junit4.SpringMethodRoadie.runTestMethod(S
> > pringMethodRoadie.java:233)
> >     at
> > org.springframework.test.context.junit4.SpringMethodRoadie$RunBeforesThen
> > TestThenAfters.run(SpringMethodRoadie.java:333)
> >     at
> >
> org.springframework.test.context.junit4.SpringMethodRoadie.runWithRepetitio
> > ns(SpringMethodRoadie.java:217)
> >     at
> >
> org.springframework.test.context.junit4.SpringMethodRoadie.runTest(SpringM
> > ethodRoadie.java:197)
> >     at
> >
> org.springframework.test.context.junit4.SpringMethodRoadie.run(SpringMetho
> > dRoadie.java:143)
> >     at
> >
>
> org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMe
> > thod(SpringJUnit4ClassRunner.java:160)
> >     at
> >
>
> org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.ja
> v
> > a:51)
> >     at
> >
>
> org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44
> )
> >     at
> >
> org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
> >     at
> > org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
> >     at
> >
> org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
> >     at
> >
>
> org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJU
> n
> > it4ClassRunner.java:97)
> >     at
> >
>
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestRef
> ere
> > nce.java:38)
> >     at
> >
>
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:3
> 8)
> >     at
> >
>
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRu
> > nner.java:460)
> >     at
> >
>
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRu
> > nner.java:673)
> >     at
> >
>
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.
> > java:386)
> >     at
> >
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunne
> > r.java:196)
> >
> >
> >
> > --
> > *
> > *twitter.com/loujianwen
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>


-- 
*
*twitter.com/loujianwen

RE: NumericField exception java.lang.IllegalStateException: call set???Value() before usage in lucene 3.5

Posted by Uwe Schindler <uw...@thetaphi.de>.
Hi,

Are you sure that you are not reusing the same NumericField instances across
different threads?

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de


> -----Original Message-----
> From: jianwen lou [mailto:loujanwen@gmail.com]
> Sent: Tuesday, March 27, 2012 9:21 AM
> To: java-user@lucene.apache.org
> Subject: NumericField exception java.lang.IllegalStateException: call
> set???Value() before usage in lucene 3.5
> 
> I want to store the long type value to my index files like follwing:
> 
>                 NumericField priceField = new NumericField("price");
>                 priceField.setDoubleValue(temp.getCurrentprice());
>                 document.add(priceField);
> 
>                 NumericField salesField = new NumericField("salescount");
>                 priceField.setLongValue(temp.getSalescount());
>                 document.add(salesField);
> 
>                 NumericField ontimefiled = new NumericField("ontime");
>                 ontimefiled.setLongValue(temp.getOntime().getTime());
>                 document.add(ontimefiled);
> 
> when writer add document i get the exception info:there is wrong with my
> using NumbericField? thanks
> 
> 
> java.lang.IllegalStateException: call set???Value() before usage
>     at
> org.apache.lucene.analysis.NumericTokenStream.reset(NumericTokenStream.j
> ava:196)
>     at
>
org.apache.lucene.index.DocInverterPerField.processFields(DocInverterPerFiel
d
> .java:130)
>     at
> org.apache.lucene.index.DocFieldProcessorPerThread.processDocument(DocFie
> ldProcessorPerThread.java:278)
>     at
> org.apache.lucene.index.DocumentsWriter.updateDocument(DocumentsWriter
> .java:766)
>     at
> org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:2066)
>     at
> com.beike.common.lucene.dao.IndexDaoImpl.saveGoodsIndex4Mobile(IndexDa
> oImpl.java:308)
>     at
> com.beike.common.lucene.dao.IndexStrategyServiceImpl.indexGoods4Mobile(I
> ndexStrategyServiceImpl.java:118)
>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
> 39)
>     at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorI
> mpl.java:25)
>     at java.lang.reflect.Method.invoke(Method.java:597)
>     at
>
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(Aop
> Utils.java:307)
>     at
> org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpo
> int(ReflectiveMethodInvocation.java:182)
>     at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(Refl
> ectiveMethodInvocation.java:149)
>     at
>
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(Tr
a
> nsactionInterceptor.java:106)
>     at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(Refl
> ectiveMethodInvocation.java:171)
>     at
>
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(Tr
a
> nsactionInterceptor.java:106)
>     at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(Refl
> ectiveMethodInvocation.java:171)
>     at
>
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(Tr
a
> nsactionInterceptor.java:106)
>     at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(Refl
> ectiveMethodInvocation.java:171)
>     at
> com.beike.ds.DataSourceInterceptor.invoke(DataSourceInterceptor.java:42)
>     at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(Refl
> ectiveMethodInvocation.java:171)
>     at
> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamic
> AopProxy.java:204)
>     at $Proxy53.indexGoods4Mobile(Unknown Source)
>     at
> com.beike.lucene.test.TestLuceneIndex.initGoodsIndex4Mobile(TestLuceneInde
> x.java:45)
>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
> 39)
>     at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorI
> mpl.java:25)
>     at java.lang.reflect.Method.invoke(Method.java:597)
>     at
>
org.springframework.test.context.junit4.SpringTestMethod.invoke(SpringTestM
> ethod.java:160)
>     at
> org.springframework.test.context.junit4.SpringMethodRoadie.runTestMethod(S
> pringMethodRoadie.java:233)
>     at
> org.springframework.test.context.junit4.SpringMethodRoadie$RunBeforesThen
> TestThenAfters.run(SpringMethodRoadie.java:333)
>     at
>
org.springframework.test.context.junit4.SpringMethodRoadie.runWithRepetitio
> ns(SpringMethodRoadie.java:217)
>     at
> org.springframework.test.context.junit4.SpringMethodRoadie.runTest(SpringM
> ethodRoadie.java:197)
>     at
> org.springframework.test.context.junit4.SpringMethodRoadie.run(SpringMetho
> dRoadie.java:143)
>     at
>
org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMe
> thod(SpringJUnit4ClassRunner.java:160)
>     at
>
org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.ja
v
> a:51)
>     at
>
org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44
)
>     at
> org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
>     at
> org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
>     at
>
org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
>     at
>
org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJU
n
> it4ClassRunner.java:97)
>     at
>
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestRef
ere
> nce.java:38)
>     at
>
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:3
8)
>     at
>
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRu
> nner.java:460)
>     at
>
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRu
> nner.java:673)
>     at
>
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.
> java:386)
>     at
>
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunne
> r.java:196)
> 
> 
> 
> --
> *
> *twitter.com/loujianwen


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


Re: NumericField exception java.lang.IllegalStateException: call set???Value() before usage in lucene 3.5

Posted by jianwen lou <lo...@gmail.com>.
thanks so much,Brandon Mintern.My mistak,sorry for everyone.

On Wed, Mar 28, 2012 at 3:12 AM, Brandon Mintern <mi...@easyesi.com>wrote:

> On Tue, Mar 27, 2012 at 12:21 AM, jianwen lou <lo...@gmail.com> wrote:
> > I want to store the long type value to my index files like follwing:
> >
> >                NumericField priceField = new NumericField("price");
> >                priceField.setDoubleValue(temp.getCurrentprice());
> >                document.add(priceField);
> >
> -->                NumericField salesField = new
> NumericField("salescount");
> -->                priceField.setLongValue(temp.getSalescount());
> >                document.add(salesField);
>
> It looks like you're setting priceField's value again instead of
> salesField's. Looks like a copy-paste that wasn't fully edited.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>


-- 
*
*twitter.com/loujianwen

Re: NumericField exception java.lang.IllegalStateException: call set???Value() before usage in lucene 3.5

Posted by Brandon Mintern <mi...@easyesi.com>.
On Tue, Mar 27, 2012 at 12:21 AM, jianwen lou <lo...@gmail.com> wrote:
> I want to store the long type value to my index files like follwing:
>
>                NumericField priceField = new NumericField("price");
>                priceField.setDoubleValue(temp.getCurrentprice());
>                document.add(priceField);
>
-->                NumericField salesField = new NumericField("salescount");
-->                priceField.setLongValue(temp.getSalescount());
>                document.add(salesField);

It looks like you're setting priceField's value again instead of
salesField's. Looks like a copy-paste that wasn't fully edited.

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