473,324 Members | 2,501 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Lucene search example

Hello,

i'm trying to compile "InMemoryExample.java" of lucene search
but i'm getting these errors!!

"C:\Java\ant_home>javac InMemoryExample.java
InMemoryExample.java:82: cannot find symbol
symbol : method UnIndexed(java.lang.String,java.lang.String)
location: class org.apache.lucene.document.Field
doc.add(Field.UnIndexed("title", title));
^
InMemoryExample.java:89: cannot find symbol
symbol : method Text(java.lang.String,java.io.StringReader)
location: class org.apache.lucene.document.Field
doc.add(Field.Text("content", new StringReader(content)));
^
InMemoryExample.java:101: parse(java.lang.String) in org.apache.lucene.queryPars
er.QueryParser cannot be applied to (java.lang.String,java.lang.String,org.apach
e.lucene.analysis.standard.StandardAnalyzer)
Query query = QueryParser.parse(queryString, "content", new StandardAnal
yzer());"


i have set related classpath for lucene packages, but still i'm getting these errors!

can any one help me?

Thanks,
Amit B.
Feb 22 '08 #1
3 8647
r035198x
13,262 8TB
Hello,

i'm trying to compile "InMemoryExample.java" of lucene search
but i'm getting these errors!!

"C:\Java\ant_home>javac InMemoryExample.java
InMemoryExample.java:82: cannot find symbol
symbol : method UnIndexed(java.lang.String,java.lang.String)
location: class org.apache.lucene.document.Field
doc.add(Field.UnIndexed("title", title));
^
InMemoryExample.java:89: cannot find symbol
symbol : method Text(java.lang.String,java.io.StringReader)
location: class org.apache.lucene.document.Field
doc.add(Field.Text("content", new StringReader(content)));
^
InMemoryExample.java:101: parse(java.lang.String) in org.apache.lucene.queryPars
er.QueryParser cannot be applied to (java.lang.String,java.lang.String,org.apach
e.lucene.analysis.standard.StandardAnalyzer)
Query query = QueryParser.parse(queryString, "content", new StandardAnal
yzer());"


i have set related classpath for lucene packages, but still i'm getting these errors!

can any one help me?

Thanks,
Amit B.
It's not a classpath issue(It would have reported that it cannot find symbol class).
For the first two errors, well, here's the spec for the Field class. As you can see those two methods are not there.
The last error message is trying hard to explain itself. Read it again.
Feb 22 '08 #2
cordeo
16
For the first two errors, ... As you can see those two methods are not there.
The last error message is trying hard to explain itself. Read it again.
That's a nice analysis of the problems, but not very helpful to a beginner. The real answer:
Your lucene jar library is newer than the one InMemoryExample was written for. Lucene changed its API. InMemoryExample is based on an older version of the API of Lucene. Changes:
1. doc.add(Field.UnIndexed("title", title));
New code:
doc.add(new Field("title", title, Field.Store.COMPRESS, Field.Index.NO));
or:
doc.add(new Field("title", title, Field.Store.YES, Field.Index.NO));

Changes: static method UnIndexed is removed and Storage Indexing options are more explicit.

2. doc.add(Field.Text("content", new StringReader(content)));
New code:
doc.add(new Field("content", content, Field.Store.NO, Field.Index.TOKENIZED));

and

3. Query query = QueryParser.parse(queryString, "content", new StandardAnalyzer());"
New code:
Query query = new QueryParser("content", new StandardAnalyzer()).parse(queryString);
or:
QueryParser queryParser = new QueryParser("content", new StandardAnalyzer());
Query query = queryParser.parse(queryString);

Change: parse is no longer static and 2 of the 3 parameters are moved to the constructor (allows for reuse).

Some backgrounds:
http://darksleep.com/lucene/ tells some things about the old API:
Field.UnIndexed(String name, String value) = Don't index, Only store
Field.Text(String name, Reader value) = Tokenized index, don't store

In general, too excessive use of the factory pattern has been removed from the API.
Jul 22 '08 #3
r035198x
13,262 8TB
That's a nice analysis of the problems, but not very helpful to a beginner. The real answer:
...
You've certainly given more detailed and yes, more helpful information.
Thanks. Teamwork in responding to threads is the key to providing complete solutions. Hope to see you around more often.
Jul 23 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Steve Jenkins | last post by:
Hi, Wonder if someone could help me. I'm looking for a PHP/MySQL based search engine that can search flat files i.e. build it's own index from flat files. I've used Apaches' Lucene before...
0
by: the_kiddie98 | last post by:
Hi, I have indexed some information from a database using the dotNet port of Lucene. If I index a field as a keyword then Lucene does not pick it up when searching. If I index the field as text...
4
by: Vic Cekvenich | last post by:
What would be performance of pgSQL text search vs MySQL vs Lucene (flat file) for a 2 terabyte db? thanks for any comments. ..V -- Please post on Rich Internet Applications User Interface...
0
by: dashprasannajit | last post by:
package djvusearching; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import org.apache.lucene.analysis.cjk.CJKAnalyzer; //import...
1
by: keith_rhodes | last post by:
Hi, all. I know that there is a way of using JavaScript to call a Java method, and for the JavaScript to collect some sort of response from the Java, as I had a page working a few years ago that...
0
by: Mirnes | last post by:
I hope someone is using Lucene.net and can help me to make it work since (in my opinion) documentation for Lucene.net is poor or I'm used to different kind of documentation. Can someone explain...
3
by: ambikadevi | last post by:
Hi, How to integrate the "Lucene Text Search" with the PHP scripts. Any idea abt this..?
4
by: sliverdigger | last post by:
I have been experimenting with Zend/Php/Lucene. I have used Lucene extensively as Java in Tomcat Servlets. Zend's php Lucene works the same way, but it is much slower to index for some...
0
by: davidvikimca | last post by:
Dear sir, I am trying some simple programs for search using lucene. I am trying to use SnowballAnalyzer in my search for "English" Language. I am using lucene-2.4.0 . On execution...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.