Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Item in collection will not be index and searched.

 

API

  • Add a new method to create a lucene index that takes a callback. The callback gives the user explicit control of how their value is converted to lucene documents and stored in the index. 
Code Block
/**
 * Create a lucene index using default analyzer.
 * @param luceneSerializer A callback which converts a region value to a 
 * Lucene document or documents to be stored in the index.
 */
public void createIndex(String indexName, String regionPath, LuceneSerializer luceneSerializer);

 
 
 
/**
 * An interface for writing the fields of an object into a lucene document
 * The region key will be added as a field to the returned documents.
 */
public interface LuceneSerializer {

  // The nested object (value) will be saved as a group of documents, in the order of 
  // child document1, child document2, parent document
  Collection<Document> toDocuments(Object value);
}


  • Use fieldnameAtLevel1.fieldnameAtLevel2 to specify a field in nested object both for indexing and querying. 

For example, a Customer object contains a Person field. A Person object contains a Page field.

...

Code Block
// Get LuceneService
LuceneService luceneService = LuceneServiceProvider.get(cache);

// Create Index on fields, some are fields in nested objects:
luceneService.createIndexFactory().setLuceneSerializer(new NestedObjectSeralizer()) /* an out-of-box LuceneSerializer implementation */
      .addField("name").addField("symbol").addField("revenue").addField("SSN")
      .addField("contact.name").addField("contact.email").addField("contact.address").addField("contact.homepage.title")
      .create("customerIndex", "Customer");

// Now to create region
Region CustomerRegion = ((Cache)cache).createRegionFactory(shortcut).create("Customer");

...