1.3. Indexing and Searching Example
Let us consider the simple case of linked Order
and Customer
entities mentioned above.
Figure 1. Data Model
In this case, if all object attributes are indexed, indexing of two related instances of Order
and Customer
will create two Lucene documents with approximately the following content:
id: Order.id = "b671dbfc-c431-4586-adcc-fe8b84ca9617"
all: Order.number + Order.date + Order.amount = "001^2013-11-14^1000"
links: Customer.id = "f18e32bb-32c7-477a-980f-06e9cc4e7f40"
id: Customer.id = "f18e32bb-32c7-477a-980f-06e9cc4e7f40"
all: Customer.name + Customer.email = "John Doe^john.doe@mail.com"
Let’s assume our search string is "john":
-
First, the search is performed in
all
fields of both documents. The system will find theCustomer
entity and will include it in search results. -
Then, the system will search for the identifier of the previously found customer in the
links
fields of all documents. The system will find theOrder
and will add it to search results as well.