Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Lucene: Java-User

KeywordAnalyzer

 

 

Lucene java-user RSS feed   Index | Next | Previous | View Threaded


pulsphoto at yahoo

Jul 1, 2009, 10:27 AM

Post #1 of 4 (335 views)
Permalink
KeywordAnalyzer

Hello,
I am using KeywordAnalyzer for one of the fields and have problem with it.
When my original term has not English characters as well as - & \ /.

Is there any alternative for this. Or how to solve the issue with
characters?


Thanks
--
View this message in context: http://www.nabble.com/KeywordAnalyzer-tp24293913p24293913.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


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


simon.willnauer at googlemail

Jul 1, 2009, 10:30 AM

Post #2 of 4 (308 views)
Permalink
Re: KeywordAnalyzer [In reply to]

On Wed, Jul 1, 2009 at 7:27 PM, John Seer<pulsphoto[at]yahoo.com> wrote:
>
> Hello,
> I am using KeywordAnalyzer for one of the fields and have problem with it.
> When my original term has not English characters as well as - &  \  /.
What are you problems? Can you elaborate this a little :)
> Is there any alternative for this. Or how to solve the issue with
> characters?
see above.


simon
>
>
> Thanks
> --
> View this message in context: http://www.nabble.com/KeywordAnalyzer-tp24293913p24293913.html
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
> For additional commands, e-mail: java-user-help[at]lucene.apache.org
>
>

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


pulsphoto at yahoo

Jul 1, 2009, 10:52 AM

Post #3 of 4 (303 views)
Permalink
Re: KeywordAnalyzer [In reply to]

Hi,

I have docs in my index like:

name: open & close
name water fall\
name: play-end-go

I am using KeywordAnalyzer to index docs and for querying

term: play-end-go

Query qp= new QueryParser("name", new KeywordAnalyzer()).parse(term);

After I am doing this I am getting error about - and if my term contains &
or \ no results

I tried to use QueryParser.escape(); before passing into parser. I am not
getting error during quering but not result is found






Simon Willnauer wrote:
>
> On Wed, Jul 1, 2009 at 7:27 PM, John Seer<pulsphoto[at]yahoo.com> wrote:
>>
>> Hello,
>> I am using KeywordAnalyzer for one of the fields and have problem with
>> it.
>> When my original term has not English characters as well as - &  \  /.
> What are you problems? Can you elaborate this a little :)
>> Is there any alternative for this. Or how to solve the issue with
>> characters?
> see above.
>
>
> simon
>>
>>
>> Thanks
>> --
>> View this message in context:
>> http://www.nabble.com/KeywordAnalyzer-tp24293913p24293913.html
>> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
>> For additional commands, e-mail: java-user-help[at]lucene.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
> For additional commands, e-mail: java-user-help[at]lucene.apache.org
>
>
>

--
View this message in context: http://www.nabble.com/KeywordAnalyzer-tp24293913p24294301.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


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


simon.willnauer at googlemail

Jul 1, 2009, 11:18 AM

Post #4 of 4 (302 views)
Permalink
Re: KeywordAnalyzer [In reply to]

Hi there,

On Wed, Jul 1, 2009 at 7:52 PM, John Seer<pulsphoto[at]yahoo.com> wrote:
>
> Hi,
>
> I have docs in my index like:
>
> name: open & close
> name water fall\
> name: play-end-go
>
> I am using KeywordAnalyzer to index docs and for querying
>
> term: play-end-go
>
> Query qp= new QueryParser("name", new KeywordAnalyzer()).parse(term);
>
> After I am doing this I am getting error about - and if my term contains &
> or \ no results
This is due to the lucene query syntax and its special chars (+ - &&
|| ! ( ) { } [ ] ^ " ~ * ? : \)
see http://lucene.apache.org/java/2_4_1/queryparsersyntax.html
>
> I tried to use QueryParser.escape(); before passing into parser. I am not
> getting error during quering but not result is found
There must be some problem somewhere else If you escape you
querystring "copy-n-paste" and you have KeywordAnalyzer for search and
indexing there should be a result.
try this:

RAMDirectory r = new RAMDirectory();
IndexWriter w = new IndexWriter(r, new KeywordAnalyzer(), true,
MaxFieldLength.UNLIMITED);
Document d = new Document();
d.add(new Field("f", "copy-n-paste", Store.NO, Index.ANALYZED));
w.addDocument(d );
w.commit();
KeywordAnalyzer ana = new KeywordAnalyzer();
QueryParser p = new QueryParser("f", ana);
IndexSearcher s = new IndexSearcher(r, true);
TopDocs search = s.search(p.parse(QueryParser.escape("copy-n-paste")),10);
System.out.println(search.totalHits);

simon
>
>
>
>
>
>
> Simon Willnauer wrote:
>>
>> On Wed, Jul 1, 2009 at 7:27 PM, John Seer<pulsphoto[at]yahoo.com> wrote:
>>>
>>> Hello,
>>> I am using KeywordAnalyzer for one of the fields and have problem with
>>> it.
>>> When my original term has not English characters as well as - &  \  /.
>> What are you problems? Can you elaborate this a little :)
>>> Is there any alternative for this. Or how to solve the issue with
>>> characters?
>> see above.
>>
>>
>> simon
>>>
>>>
>>> Thanks
>>> --
>>> View this message in context:
>>> http://www.nabble.com/KeywordAnalyzer-tp24293913p24293913.html
>>> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
>>> For additional commands, e-mail: java-user-help[at]lucene.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
>> For additional commands, e-mail: java-user-help[at]lucene.apache.org
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/KeywordAnalyzer-tp24293913p24294301.html
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
> For additional commands, e-mail: java-user-help[at]lucene.apache.org
>
>

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

Lucene java-user RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.