Mailing List Archive

partial search
How could I make a search with something like "tes*" for test, testing, ...?

Currently, I use a StandardAnalyzer for indexing and searching (with query
parser), and it doesn't work.
Do I need to use another analyser ?

TY.
-----
Christophe


--
To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>
Re: partial search [ In reply to ]
> How could I make a search with something like "tes*" for test, testing, ...?
>
> Currently, I use a StandardAnalyzer for indexing and searching (with query
> parser), and it doesn't work.
> Do I need to use another analyser ?

I don't think so. The short program below works for me with lucene-1.2-rc2.


--
Ian.
ian.lea@blackwell.co.uk


import org.apache.lucene.queryParser.*;
import org.apache.lucene.search.*;
import org.apache.lucene.index.*;
import org.apache.lucene.analysis.*;
import org.apache.lucene.analysis.standard.*;
import org.apache.lucene.document.*;


public class Test {

public static void main(String args[]) throws Exception {
Analyzer analyzer = new StandardAnalyzer();
IndexWriter writer = new IndexWriter("test", analyzer, true);
Document d;
d = new Document();
d.add(Field.Text("word", "test"));
writer.addDocument(d);
d = new Document();
d.add(Field.Text("word", "testing"));
writer.addDocument(d);
writer.close();
IndexReader reader = IndexReader.open("test");
Searcher searcher = new IndexSearcher(reader);
String s = "test*";
if (args.length > 0) { s = args[0]; }
Query query = QueryParser.parse(s, "word", analyzer);
Hits hits = searcher.search(query);
for (int i = 0; i < hits.length(); i++) {
System.out.println(hits.doc(i).get("word"));
}
}
}

--
To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>
Re: partial search [ In reply to ]
After some test, I found there was a difference between "tes*" and "TES*".
It seems to not work with uppercase and *.
however it works fine with "test" and "TEST".
It happend only with the '*'.

-----
Christophe

----- Message d'origine -----
De : "Ian Lea" <ian.lea@blackwell.co.uk>
À : "Lucene Users List" <lucene-user@jakarta.apache.org>; <cgd@free.fr>
Envoyé : mardi 6 novembre 2001 22:51
Objet : Re: partial search


> > How could I make a search with something like "tes*" for test, testing,
...?
> >
> > Currently, I use a StandardAnalyzer for indexing and searching (with
query
> > parser), and it doesn't work.
> > Do I need to use another analyser ?
>
> I don't think so. The short program below works for me with
lucene-1.2-rc2.
>
>
> --
> Ian.
> ian.lea@blackwell.co.uk
>
>
> import org.apache.lucene.queryParser.*;
> import org.apache.lucene.search.*;
> import org.apache.lucene.index.*;
> import org.apache.lucene.analysis.*;
> import org.apache.lucene.analysis.standard.*;
> import org.apache.lucene.document.*;
>
>
> public class Test {
>
> public static void main(String args[]) throws Exception {
> Analyzer analyzer = new StandardAnalyzer();
> IndexWriter writer = new IndexWriter("test", analyzer, true);
> Document d;
> d = new Document();
> d.add(Field.Text("word", "test"));
> writer.addDocument(d);
> d = new Document();
> d.add(Field.Text("word", "testing"));
> writer.addDocument(d);
> writer.close();
> IndexReader reader = IndexReader.open("test");
> Searcher searcher = new IndexSearcher(reader);
> String s = "test*";
> if (args.length > 0) { s = args[0]; }
> Query query = QueryParser.parse(s, "word", analyzer);
> Hits hits = searcher.search(query);
> for (int i = 0; i < hits.length(); i++) {
> System.out.println(hits.doc(i).get("word"));
> }
> }
> }
>


--
To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>
Re: partial search [ In reply to ]
Yes, and here is the explanation, if you are interested:
http://www.jguru.com/faq/view.jsp?EID=538312

Otis

--- Christophe <cgd@free.fr> wrote:
> After some test, I found there was a difference between "tes*" and
> "TES*".
> It seems to not work with uppercase and *.
> however it works fine with "test" and "TEST".
> It happend only with the '*'.
>
> -----
> Christophe
>
> ----- Message d'origine -----
> De : "Ian Lea" <ian.lea@blackwell.co.uk>
> À : "Lucene Users List" <lucene-user@jakarta.apache.org>;
> <cgd@free.fr>
> Envoyé : mardi 6 novembre 2001 22:51
> Objet : Re: partial search
>
>
> > > How could I make a search with something like "tes*" for test,
> testing,
> ...?
> > >
> > > Currently, I use a StandardAnalyzer for indexing and searching
> (with
> query
> > > parser), and it doesn't work.
> > > Do I need to use another analyser ?
> >
> > I don't think so. The short program below works for me with
> lucene-1.2-rc2.
> >
> >
> > --
> > Ian.
> > ian.lea@blackwell.co.uk
> >
> >
> > import org.apache.lucene.queryParser.*;
> > import org.apache.lucene.search.*;
> > import org.apache.lucene.index.*;
> > import org.apache.lucene.analysis.*;
> > import org.apache.lucene.analysis.standard.*;
> > import org.apache.lucene.document.*;
> >
> >
> > public class Test {
> >
> > public static void main(String args[]) throws Exception {
> > Analyzer analyzer = new StandardAnalyzer();
> > IndexWriter writer = new IndexWriter("test", analyzer, true);
> > Document d;
> > d = new Document();
> > d.add(Field.Text("word", "test"));
> > writer.addDocument(d);
> > d = new Document();
> > d.add(Field.Text("word", "testing"));
> > writer.addDocument(d);
> > writer.close();
> > IndexReader reader = IndexReader.open("test");
> > Searcher searcher = new IndexSearcher(reader);
> > String s = "test*";
> > if (args.length > 0) { s = args[0]; }
> > Query query = QueryParser.parse(s, "word", analyzer);
> > Hits hits = searcher.search(query);
> > for (int i = 0; i < hits.length(); i++) {
> > System.out.println(hits.doc(i).get("word"));
> > }
> > }
> > }
> >
>
>
> --
> To unsubscribe, e-mail:
> <mailto:lucene-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:lucene-user-help@jakarta.apache.org>
>


__________________________________________________
Do You Yahoo!?
Find a job, post your resume.
http://careers.yahoo.com

--
To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>
Re: partial search [ In reply to ]
ok, thank you.

-----
Christophe

----- Message d'origine -----
De : "Otis Gospodnetic" <otis_gospodnetic@yahoo.com>
À : "Lucene Users List" <lucene-user@jakarta.apache.org>
Envoyé : mercredi 7 novembre 2001 16:23
Objet : Re: partial search


> Yes, and here is the explanation, if you are interested:
> http://www.jguru.com/faq/view.jsp?EID=538312
>
> Otis
>
> --- Christophe <cgd@free.fr> wrote:
> > After some test, I found there was a difference between "tes*" and
> > "TES*".
> > It seems to not work with uppercase and *.
> > however it works fine with "test" and "TEST".
> > It happend only with the '*'.
> >
> > -----
> > Christophe
> >
> > ----- Message d'origine -----
> > De : "Ian Lea" <ian.lea@blackwell.co.uk>
> > À : "Lucene Users List" <lucene-user@jakarta.apache.org>;
> > <cgd@free.fr>
> > Envoyé : mardi 6 novembre 2001 22:51
> > Objet : Re: partial search
> >
> >
> > > > How could I make a search with something like "tes*" for test,
> > testing,
> > ...?
> > > >
> > > > Currently, I use a StandardAnalyzer for indexing and searching
> > (with
> > query
> > > > parser), and it doesn't work.
> > > > Do I need to use another analyser ?
> > >
> > > I don't think so. The short program below works for me with
> > lucene-1.2-rc2.
> > >
> > >
> > > --
> > > Ian.
> > > ian.lea@blackwell.co.uk
> > >
> > >
> > > import org.apache.lucene.queryParser.*;
> > > import org.apache.lucene.search.*;
> > > import org.apache.lucene.index.*;
> > > import org.apache.lucene.analysis.*;
> > > import org.apache.lucene.analysis.standard.*;
> > > import org.apache.lucene.document.*;
> > >
> > >
> > > public class Test {
> > >
> > > public static void main(String args[]) throws Exception {
> > > Analyzer analyzer = new StandardAnalyzer();
> > > IndexWriter writer = new IndexWriter("test", analyzer, true);
> > > Document d;
> > > d = new Document();
> > > d.add(Field.Text("word", "test"));
> > > writer.addDocument(d);
> > > d = new Document();
> > > d.add(Field.Text("word", "testing"));
> > > writer.addDocument(d);
> > > writer.close();
> > > IndexReader reader = IndexReader.open("test");
> > > Searcher searcher = new IndexSearcher(reader);
> > > String s = "test*";
> > > if (args.length > 0) { s = args[0]; }
> > > Query query = QueryParser.parse(s, "word", analyzer);
> > > Hits hits = searcher.search(query);
> > > for (int i = 0; i < hits.length(); i++) {
> > > System.out.println(hits.doc(i).get("word"));
> > > }
> > > }
> > > }
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:lucene-user-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail:
> > <mailto:lucene-user-help@jakarta.apache.org>
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Find a job, post your resume.
> http://careers.yahoo.com
>
> --
> To unsubscribe, e-mail:
<mailto:lucene-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:lucene-user-help@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>