Versions Compared

Key

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

...

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

// Create Index on fields, some are fields in nested objects:
luceneService.createIndexFactory().setLuceneSerializer(new NestedObjectSeralizerFlatformatSeralizer()) /* 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");

...

Code Block
LuceneQuery query = luceneService.createLuceneQueryFactory().create("customerIndex", "Customer", "contact.email:tzhou11*", "name");
 
PageableLuceneQueryResults<K,Object> results = query.findPages();

 

...

Out-Of-Box implementation

We'll provide an out-of-box implementation for the LuceneSerializer: FlatformatSerializer.

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 will convert a Customer object into a document as

(name:John11), (symbol:123), (revenue:121939), (SSN:1233227171),(contact.name:tzhou11), (contact.email:tzhou11@gmail.com), (contact.address:15220 Wall St), (contact.homepage.id:11), (contact.homepage.title: Mr. tzhou11), (contact.homepage.content: xxx)