Lucene stringField EnglishAnalyzer search not working

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Lucene stringField EnglishAnalyzer search not working

egorlex
This post was updated on .
Hi, please help..

I need exact match for my search for one field. I make it by stringField,
but it is not working no search result.I tried lowercase , but it still no
result in search.  I tried text field and it works but it is no exact
match..
I use EnglishAnalyzer

Thanks!



--
Sent from: http://lucene.472066.n3.nabble.com/Lucene-Java-Users-f532864.html

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

Reply | Threaded
Open this post in threaded view
|

Re: Lucene stringField EnglishAnalyzer serch nor working

Erick Erickson
Please provide specific examples of what you mean.
along with the fieldType you tried, an example of
what the input at index time for the field, and examples
of what searches "didn't work". What exactly did
you expect to happen that didn't?

You might review:
https://wiki.apache.org/solr/UsingMailingLists

But at a blind guess, I'd expect you want a
solr.TextField-based field with
KeywordTokenizer and LowercaseFilter.

There are usually examples in the distributed schemas, but
it's impossible to tell in your case because you haven't
told us what version of Solr you're using.

Best,
Erick

On Fri, Jul 20, 2018 at 4:22 AM, egorlex <[hidden email]> wrote:

> Hi, please help..
>
> I need exact match for my search for one field. I make it by stringField,
> but it is not working no search result.I tried lowercase   but it still no
> result in search.  I tried text field and it works but it is no exact
> match..
> I use EnglishAnalyzer
>
> Thanks!
>
>
>
> --
> Sent from: http://lucene.472066.n3.nabble.com/Lucene-Java-Users-f532864.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Lucene stringField EnglishAnalyzer serch nor working

egorlex
Hi Erick,

Thanks for reply,

In need find document by  uuid (random generated field).

Example of create field in document:

Document document = new Document();
document.add(new StringField("uuid", product.getId() , Field.Store.YES));

Example of query to search:

Map<String, Float> boosts = new HashMap<>();
      boosts.put("uuid", 1.0f);
      boosts.put("name", 1.0f);

String[] fields = new String[]{"uuid",  "name"};

MultiFieldQueryParser multiQP = new MultiFieldQueryParser(fields,
engAnalyzer, boosts);
quary = multiQP.parse(query);

TopDocs hits = sercher.search(query, maxResult, sort);

I wont to find document by uuid but result is always empty.

Everything works if i create document with text field
document.add(new TextField("uuid", product.getId() , Field.Store.YES));
But i need exact match... this approach good for name but not for uuid.

Lucene version 7.3.0

Thanks.







--
Sent from: http://lucene.472066.n3.nabble.com/Lucene-Java-Users-f532864.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Lucene stringField EnglishAnalyzer serch nor working

Erick Erickson
Why so complicated? Boosts do you no good,
you're only trying to find one document. Boosts influence
the score of documents in the ranking, but there's
only one.

I suspect if you looked at the debug form of the parsed query,
you'd find it pretty unexpected. You say it works  with
text fields, but I also suspect it's not doing quite what
you expect.

And it's all unnecessary and overly expensive anyway.
Just use a TermQuery. Term queries are very stupid and
do _no_ analysis of the term provided, they expect that
you already have done all that. They're very, very
efficient.

Best,
Erick

On Fri, Jul 20, 2018 at 9:30 AM, egorlex <[hidden email]> wrote:

> Hi Erick,
>
> Thanks for reply,
>
> In need find document by  uuid (random generated field).
>
> Example of create field in document:
>
> Document document = new Document();
> document.add(new StringField("uuid", product.getId() , Field.Store.YES));
>
> Example of query to search:
>
> Map<String, Float> boosts = new HashMap<>();
>       boosts.put("uuid", 1.0f);
>       boosts.put("name", 1.0f);
>
> String[] fields = new String[]{"uuid",  "name"};
>
> MultiFieldQueryParser multiQP = new MultiFieldQueryParser(fields,
> engAnalyzer, boosts);
> quary = multiQP.parse(query);
>
> TopDocs hits = sercher.search(query, maxResult, sort);
>
> I wont to find document by uuid but result is always empty.
>
> Everything works if i create document with text field
> document.add(new TextField("uuid", product.getId() , Field.Store.YES));
> But i need exact match... this approach good for name but not for uuid.
>
> Lucene version 7.3.0
>
> Thanks.
>
>
>
>
>
>
>
> --
> Sent from: http://lucene.472066.n3.nabble.com/Lucene-Java-Users-f532864.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]