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 Carlos de Luna Saenz <cd...@yahoo.com.mx> on 2012/10/24 19:55:56 UTC

SortField.STRING

I am migrating code from Lucene 3 to Lucene 4... and i have the following code that i don't know how to change:
 
hits = searcher.search(queryGlobal, searcher.maxDoc(),
                    new Sort(new SortField(ordenarPor, SortField.STRING)));
 
I already change the searcher.maxDoc() to indxr.maxDoc() but SortField.STRING does not exist anymore... what do i have to do?
In the same code i have a class called SpanishAnalyzer:
public class SpanishAnalyzer  extends Analyzer {
     public static final String[] SPANISH_STOP_WORDS = { "." };  
     
     private Set<Object> stopTable = new HashSet<Object>();  
     
     private Set<Object> exclTable = new HashSet<Object>();  
    
     public SpanishAnalyzer() {  
        stopTable = StopFilter.makeStopSet(Version.LUCENE_40,SPANISH_STOP_WORDS);  
        
    }  
     public SpanishAnalyzer(Version version){
         stopTable = StopFilter.makeStopSet(version,SPANISH_STOP_WORDS);
     }
     
     public SpanishAnalyzer(String[] stopWords) {  
        stopTable = StopFilter.makeStopSet(Version.LUCENE_40,stopWords);  
    }
     public SpanishAnalyzer(File stopWords) throws IOException {  
        stopTable = new HashSet(WordlistLoader.getWordSet(new FileReader(stopWords), Version.LUCENE_40));  
    }
    
//    @Override
//    public TokenStream tokenStream(String fieldName, Reader reader) {
//        return new LowerCaseFilter(Version.LUCENE_40,new ASCIIFoldingFilter(
//                new StopFilter(Version.LUCENE_40,
//                                new StandardTokenizer(Version.LUCENE_40,
//                                                      reader), 
//                                stopTable)));
//    }
    @Override
    protected TokenStreamComponents createComponents(String string, Reader reader) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
}

The problem is that i can't override TokenStream anymore and now i have to implement the createComponents method and i am not sure what do i supposed to do there... thanks in advance for both troubles.

Re: SortField.STRING

Posted by Carlos de Luna Saenz <cd...@yahoo.com.mx>.
Thanks... that's it... sorry to siturb with something that simple.





>________________________________
> De: Ian Lea <ia...@gmail.com>
>Para: java-user@lucene.apache.org; Carlos de Luna Saenz <cd...@yahoo.com.mx> 
>Enviado: Miércoles, 24 de octubre, 2012 1:55 P.M.
>Asunto: Re: SortField.STRING
> 
>SortField.Type.STRING maybe?
>
>Can't help with the other question.  It's generally best to send one
>question per message.  Looking at the source code might help.
>
>
>--
>Ian.
>
>
>On Wed, Oct 24, 2012 at 6:55 PM, Carlos de Luna Saenz
><cd...@yahoo.com.mx> wrote:
>> I am migrating code from Lucene 3 to Lucene 4... and i have the following code that i don't know how to change:
>>
>> hits = searcher.search(queryGlobal, searcher.maxDoc(),
>>                     new Sort(new SortField(ordenarPor, SortField.STRING)));
>>
>> I already change the searcher.maxDoc() to indxr.maxDoc() but SortField.STRING does not exist anymore... what do i have to do?
>> In the same code i have a class called SpanishAnalyzer:
>> public class SpanishAnalyzer  extends Analyzer {
>>      public static final String[] SPANISH_STOP_WORDS = { "." };
>>
>>      private Set<Object> stopTable = new HashSet<Object>();
>>
>>      private Set<Object> exclTable = new HashSet<Object>();
>>
>>      public SpanishAnalyzer() {
>>         stopTable = StopFilter.makeStopSet(Version.LUCENE_40,SPANISH_STOP_WORDS);
>>
>>     }
>>      public SpanishAnalyzer(Version version){
>>          stopTable = StopFilter.makeStopSet(version,SPANISH_STOP_WORDS);
>>      }
>>
>>      public SpanishAnalyzer(String[] stopWords) {
>>         stopTable = StopFilter.makeStopSet(Version.LUCENE_40,stopWords);
>>     }
>>      public SpanishAnalyzer(File stopWords) throws IOException {
>>         stopTable = new HashSet(WordlistLoader.getWordSet(new FileReader(stopWords), Version.LUCENE_40));
>>     }
>>
>> //    @Override
>> //    public TokenStream tokenStream(String fieldName, Reader reader) {
>> //        return new LowerCaseFilter(Version.LUCENE_40,new ASCIIFoldingFilter(
>> //                new StopFilter(Version.LUCENE_40,
>> //                                new StandardTokenizer(Version.LUCENE_40,
>> //                                                      reader),
>> //                                stopTable)));
>> //    }
>>     @Override
>>     protected TokenStreamComponents createComponents(String string, Reader reader) {
>>         throw new UnsupportedOperationException("Not supported yet.");
>>     }
>>
>> }
>>
>> The problem is that i can't override TokenStream anymore and now i have to implement the createComponents method and i am not sure what do i supposed to do there... thanks in advance for both troubles.
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>For additional commands, e-mail: java-user-help@lucene.apache.org
>
>
>
>

Re: SortField.STRING

Posted by Ian Lea <ia...@gmail.com>.
SortField.Type.STRING maybe?

Can't help with the other question.  It's generally best to send one
question per message.  Looking at the source code might help.


--
Ian.


On Wed, Oct 24, 2012 at 6:55 PM, Carlos de Luna Saenz
<cd...@yahoo.com.mx> wrote:
> I am migrating code from Lucene 3 to Lucene 4... and i have the following code that i don't know how to change:
>
> hits = searcher.search(queryGlobal, searcher.maxDoc(),
>                     new Sort(new SortField(ordenarPor, SortField.STRING)));
>
> I already change the searcher.maxDoc() to indxr.maxDoc() but SortField.STRING does not exist anymore... what do i have to do?
> In the same code i have a class called SpanishAnalyzer:
> public class SpanishAnalyzer  extends Analyzer {
>      public static final String[] SPANISH_STOP_WORDS = { "." };
>
>      private Set<Object> stopTable = new HashSet<Object>();
>
>      private Set<Object> exclTable = new HashSet<Object>();
>
>      public SpanishAnalyzer() {
>         stopTable = StopFilter.makeStopSet(Version.LUCENE_40,SPANISH_STOP_WORDS);
>
>     }
>      public SpanishAnalyzer(Version version){
>          stopTable = StopFilter.makeStopSet(version,SPANISH_STOP_WORDS);
>      }
>
>      public SpanishAnalyzer(String[] stopWords) {
>         stopTable = StopFilter.makeStopSet(Version.LUCENE_40,stopWords);
>     }
>      public SpanishAnalyzer(File stopWords) throws IOException {
>         stopTable = new HashSet(WordlistLoader.getWordSet(new FileReader(stopWords), Version.LUCENE_40));
>     }
>
> //    @Override
> //    public TokenStream tokenStream(String fieldName, Reader reader) {
> //        return new LowerCaseFilter(Version.LUCENE_40,new ASCIIFoldingFilter(
> //                new StopFilter(Version.LUCENE_40,
> //                                new StandardTokenizer(Version.LUCENE_40,
> //                                                      reader),
> //                                stopTable)));
> //    }
>     @Override
>     protected TokenStreamComponents createComponents(String string, Reader reader) {
>         throw new UnsupportedOperationException("Not supported yet.");
>     }
>
> }
>
> The problem is that i can't override TokenStream anymore and now i have to implement the createComponents method and i am not sure what do i supposed to do there... thanks in advance for both troubles.

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