You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Jairo Sánchez <ja...@yahoo.es> on 2006/01/29 22:30:32 UTC

Term

I don't Know if anyone could help me with this issue:
   
  for the requirements of the application i'm doing i need to store the terms (i.e the words) inverted, i mean, for example i need the word "horse" to be stored as "esroh" because in my application i need to find all the words in the index  that end in an specific suffix. 
   
  Can anyone send me an idea for doing it?
  I thought in inverting the files before indexing it but it would increase the time complexity of the program.

		
---------------------------------

LLama Gratis a cualquier PC del Mundo.
Llamadas a fijos y móviles desde 1 céntimo por minuto.
http://es.voice.yahoo.com

Re: Term

Posted by Chris Hostetter <ho...@fucit.org>.
: terms (i.e the words) inverted, i mean, for example i need the word
: "horse" to be stored as "esroh" because in my application i need to find
: all the words in the index that end in an specific suffix.

:   I thought in inverting the files before indexing it but it would
: increase the time complexity of the program.

Ouch.  Please don't do that.  It hurts my brain just to think about it.

This is the kind of problem TokenFilters were invented for.  you can write
one that reverses the tokenText in the token it's recieved on the
TokenStream.

you can index the text in two fields (forwards and backwords) or if you
want the reversed versions of the terms in the same field as the "forward"
versions, then your TokenFilter can echo the orriginal Token, and then
output your reversed versions with the same positionIncriment (to keep
phrases working) .. but if you don't want people looking for
"god" complaining about all the "dog" results they get, i would preface
all of your reversed tokens with some character that your tokenizer would
normally strip out -- and when you detect that the user is doing a suffiz
search, prepend it to the reversed string

ie:   new PrefixQuery(new Term(fieldName,"_esr"));


-Hoss


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