lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shai Erera <ser...@gmail.com>
Subject Re: A question about FacetField constructor
Date Sun, 22 Jun 2014 07:23:31 GMT
What do you mean by does not index anything? Do you get an exception when
you add a String[] with more than one element?

You should probably call conf.setHierarchical(dimension), but if you don't
do that you should receive an IllegalArgumentException telling you to do
that...

Shai


On Sun, Jun 22, 2014 at 6:34 AM, west suhanic <west.suhanic@gmail.com>
wrote:

> Hello All:
>
> I am building sample code using lucene v4.8.1 to explore
> the new facet API. The problem I am having is that if I pass
> a populated string array nothing gets indexed while if
> I pass only the first element of the string array that value gets indexed.
> The code found below shows the case that works and the case that does not
> work. What am I doing wrong?
>
> ****************Start of code sample*************************
>
> void showStuff( String... va )
> {
>               /** This code permits out the contents of va successfully.**/
>               for( int ii = 0 ; ii < va.length ; ii++ )
>                       System.out.println( "value[" + ii + "] " + va[ii] );
> }
>
>                 for( final Map< String, String[] > fd : allFacetData )
>                 {
>
>                         final Document doc = new Document();
>                         for( final Map.Entry< String, String[] > entry :
> fd.entrySet() )
>                         {
>                                 final String key = entry.getKey();
>                                 String[] value = entry.getValue();
>                                 showStuff( value );
>
>                                 /**  This call indexes successfully **/
>                                 final FacetField newFF = new FacetField(
> key, value[0] );
>
>                                 /**
>                                    * This call will not index anything if
> the value String array
>                                    * has more than one element.
>                                    *final FacetField newFF = new
> FacetField( key, value );
>                                    */
>                                 doc.add( newFF );
>                         }
>
>                         try
>                         {
>                                 final Document theBuildDoc =
> configFacetsHandle.
> build( taxoWriter, doc );
>                                 indexWriter.addDocument( theBuildDoc );
>                                 indexWriter.addDocument(
> configFacetsHandle.buil
> d( taxoWriter, doc ) );
>                         }
>                         catch( IOException ioe )
>                         {
>                                 eMsg.append( method );
>                                 eMsg.append(  " failed with the exception "
> );
>                                 eMsg.append( ioe.toString() );
>                                 return constantValuesInterface.FAILURE;
>                         }
>                 }
>
> *******************End of code sample***************
>
> regards,
>
> West Suhanic
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message