lucene - Java, cannot find symbol : method methodName(org.bla.blabla.myClass) -


i'm using lucene apis, , following error on line of code:

import org.apache.lucene.document.document; import org.apache.lucene.document.field; import org.apache.lucene.document.fieldable;  ...  document _document  = new document(); _document.add(new field("type", document.gettype())); 

error: collectionindexer.java:34: cannot find symbol symbol : method add(org.apache.lucene.document.field) location: class collectionindexer.document _document.add(new field("type", document.gettype()));

this documentation method: http://lucene.apache.org/java/3_0_3/api/all/org/apache/lucene/document/document.html#add(org.apache.lucene.document.fieldable)

thanks

update: javac -cp commons-digester-2.1/commons-digester-2.1.jar:lucene-core-3.0.3.jar myapp.java

the problem comes fact document.gettype() method returns string , there no constructor in field class matches call. see http://lucene.apache.org/java/3_0_3/api/all/org/apache/lucene/document/field.html.

if test code in environment eclipse says:

the constructor field(string, string) undefined

maybe following:

document _document = new document(); _document.add(new field("type", document.gettype().getbytes(), store.yes); // or document.add(new field("type", document.gettype().getbytes(), store.no); 

update after source code submission --------------------

the problem comes fact in class have inner-class called document. there name conflict between document class , lucene's one. when instanciate document line document _document = new document(); you're instanciating document class. that's why compiler cannot find add method.

multiple solution:

a. instanciate document prefixing lucene package name

org.apache.lucene.document.document _document = new org.apache.lucene.document.document(); 

b. rename inner class don't have name conflict.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -