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 "m.harig" <m....@gmail.com> on 2009/09/09 08:38:42 UTC

get all tokens from index

hello all ,

       is there any way to get all tokens from my index ? please anyone
suggest me
-- 
View this message in context: http://www.nabble.com/get-all-tokens-from-index-tp25359411p25359411.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


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


Re: get all tokens from index

Posted by "m.harig" <m....@gmail.com>.
Thanks Ahmet , i found the solution. thanks a lot


Ahmet Arslan wrote:
> 
> 
>> hello all, is there any way to get all
>> tokens from my index ? please anyone
>> suggest me
> 
> The code below prints all terms of a field.
> 
>        String path = "E:\\ThesaurusSolrHome\\data\\index";
>        String field = "contents";
> 
>         IndexReader indexReader = IndexReader.open(path);
>         TermEnum termEnum = indexReader.terms();
> 
>         while (termEnum.next()) {
>             Term term = termEnum.term();
>             if (term.field().equalsIgnoreCase(field))
>                 System.out.println(term.text());
> 
>         }
>         termEnum.close();
>         indexReader.close();
> 
> 
>       
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/get-all-tokens-from-index-tp25359411p25359857.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


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


Re: get all tokens from index

Posted by AHMET ARSLAN <io...@yahoo.com>.
> hello all, is there any way to get all
> tokens from my index ? please anyone
> suggest me

The code below prints all terms of a field.

       String path = "E:\\ThesaurusSolrHome\\data\\index";
       String field = "contents";

        IndexReader indexReader = IndexReader.open(path);
        TermEnum termEnum = indexReader.terms();

        while (termEnum.next()) {
            Term term = termEnum.term();
            if (term.field().equalsIgnoreCase(field))
                System.out.println(term.text());

        }
        termEnum.close();
        indexReader.close();


      

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