THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
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 { Collection<Document> toDocuments(Object value); } |
- Will provide a built-in implementation for LuceneSerializer. Use fieldnameAtLevel1.fieldnameAtLevel2 to specify a field in nested object both for indexing and querying.
...
Code Block |
---|
// Get LuceneService LuceneService luceneService = LuceneServiceProvider.get(cache); // Create Index on fields, some are fields in nested objects: luceneService.createIndexFactory().setLuceneSerializer(new FlatformatSeralizerFlatFormatSeralizer()) /* an out-of-box LuceneSerializer implementation */ .addField("name").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"); |
...
We'll provide an out-of-box implementation for the LuceneSerializer: FlatformatSerializerFlatFormatSerializer.
It will still create one document for each parent object. But add the nest object as embeded fields of the document. The field name will use the qualified name.
For example, the FlatformatSerializer FlatFormatSerializer will convert a Customer object into a document as
...