Difference between revisions of "Opentaps Search Feature"

From Opentaps Wiki
Jump to navigationJump to search
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
  This is a conceptual document and the features described here are being implemented
 
 
 
__TOC__
 
__TOC__
  
 
== Architecture ==
 
== Architecture ==
  
The basic idea is to use [https://www.hibernate.org/410.html Hibernate Search] to index data in the opentaps database, and then have a search tool which allows you to find results based on keywords rather than explicit parameters like on a find form.  This is however different than [http://www.google.com/enterprise/gsa/ Google Enterprise Search] which is designed to index documents rather than database table values. However, the overall architecture should support integration to external search interfaces such as [http://www.google.com/enterprise/gsa/ Google Enterprise Search] fairly easily.
+
The basic idea is to use [https://www.hibernate.org/410.html Hibernate Search] to index data in the opentaps database, and then have a search tool which allows you to find results based on keywords rather than explicit parameters like on a find form.  The overall architecture should support integration to external search interfaces such as [http://www.google.com/enterprise/gsa/ Google Enterprise Search] fairly easily.
 +
 
 +
Search is a form of data retrieval similar to SQL.    To make it easy for you to switch one search service for another, we have created a search domain based on the  [[Domain Driven Architecture]].  All basic search functionality is implemented in this domain, even though they may the searching other domains.  In the search domain you would therefore find services for parties, accounts, contacts, leads, and suppliers as well as for quotes, sales opportunities, sales orders, and purchase orders. 
 +
 
 +
Each application (CRM, purchasing, etc.) can then have its own search service which reuses best search components from the common search domain.  For example <tt>CrmsfaSearchService</tt> will access the account, contact, lead, order, sales opportunity, etc. search services.  It has method such as getAccounts(), getContacts(), getSalesOpportunities(), getSalesOrders() to return lists of entity objects.  Purchasing initially will just have search of the suppliers and orders domain to getSuppliers() and getPurchaseOrders().
 +
 
 +
Implementing search this way makes it easier to replace one search technology with another. For example, one day we may have a document management domain in opentaps, and there could be a DocumentSearchServiceInterface in this domain.  This  interface might specify that for a set of keywords, it will return a List<Document> of Document  objects which might have the names, summaries, and links to the actual documents. In one implementation, we might use the Google Search Appliance  to implement the DocumentDomainSearchInterface, but in another instance, we could use a  different document indexing and search tool.  Applications such as CRM and purchasing could then call on the document domain to search for documents, while being separated from the actual implementation of the indexing and search.
 +
 
 +
== Configuration ==
 +
 
 +
The indexing of entities for search is configured by <tt>hot-deploy/opentaps-common/config/entitysearch.properties</tt>.  You can configure an entity to be indexed:
 +
SalesOpportunity = index
 +
 
 +
And you can also configure the weights of the entity's fields:
 +
SalesOpportunity.salesOpportunityId = 1
 +
SalesOpportunity.opportunityName = 10
 +
SalesOpportunity.description = 1
 +
SalesOpportunity.nextStep = 1
 +
 
 +
Sometimes you'll have to index  entities such as SalesOpportunityRole or PartyRole,  so that the search services can use them to determine the type of party and whether it is an account, contact, or lead.
 +
 
 +
Note that view entities can not be indexed, since they are not actually stored in the database.
  
  Now these are just my notes
+
== Integration with Persistence Layer ==
  
<pre>
+
Because we are using hibernate search, data stored with hibernate will automatically be indexed.
  
Each domain has a search capability: DomainSearch: ie --> AccountsSearch.searchByKeyword(...) -> List<Account>
+
For data stored using the ofbiz entity engine, opentaps uses [http://en.wikipedia.org/wiki/Aspect-oriented_programming  aspect oriented programming] (AOP) to intercept the ofbiz delegator's Entity-Event-Condition-Action (EECA) sequence.   Normally, after the delegator stores a value, it will evaluate EECA's attached to the entity  to see if any services should be run.   opentaps has added an aspect to the ofbiz delegator, so that it will also index the entity stored.
SalesOpportunity.searchByKeyword(...) -> List<SalesOpportunity>
 
  
so each application (CRM, purchasing, etc.) can have a SearchService
+
==  Displaying Search Results ==
which you can do setKeyWord(...); maybe some other set parameters.
 
then search() and then getAccounts() getContacts() getSalesOpportunities()
 
  
And then purchasing just has a search which allows you to getSuppliers() for now
+
The results of the search should be passed to our GWT EntityListViews so that the webapps could display them.
  
the results of the search should be passed to our GWT EntityListViews so that the webapps could display them.
+
== Clearing Search Indices ==
  
hibernate search should be set to configure entities and fields and their weights
+
The hibernate search index files are located in <tt>runtime/lucene/indexes</tt> (this is defined in <tt>org.opentaps.domain.container.HibernateCfgGeneratorContainer.java</tt>) and can be cleared by
so for example, if I want SalesOpportunity.opportunityName to weigh 10x as much as SalesOpportunity.description
 
similar to applications/product/config/prodsearch.properties
 
  
the other thing we need is AOP on the delegator to index the entities as they are stored by delegator and do it in 1 transaction prior to ofbiz committing so we don't open up more transactions
+
$ ant refresh
  
here's a good thought experiment:
+
After clearing them, you will need to run the <tt>opentaps.createHibernateSearchIndex</tt> service again to re-build them.
what if we integrate in Google Search Appliance which indexes your documents
 
so...let's say it's part of CRM and we want to link to documents
 
so we drop a new DocumentDomainSearchInterface/Impl into opentaps CRM
 
I guess what we need is a method in CRMSearchInterface/Impl which returns a link and a description for each result in the List<Document>
 
and then implement Google Search Appliance as one kind of DocumentDomainSearchInterface
 
</pre>
 

Latest revision as of 18:45, 1 March 2010

Architecture

The basic idea is to use Hibernate Search to index data in the opentaps database, and then have a search tool which allows you to find results based on keywords rather than explicit parameters like on a find form. The overall architecture should support integration to external search interfaces such as Google Enterprise Search fairly easily.

Search is a form of data retrieval similar to SQL. To make it easy for you to switch one search service for another, we have created a search domain based on the Domain Driven Architecture. All basic search functionality is implemented in this domain, even though they may the searching other domains. In the search domain you would therefore find services for parties, accounts, contacts, leads, and suppliers as well as for quotes, sales opportunities, sales orders, and purchase orders.

Each application (CRM, purchasing, etc.) can then have its own search service which reuses best search components from the common search domain. For example CrmsfaSearchService will access the account, contact, lead, order, sales opportunity, etc. search services. It has method such as getAccounts(), getContacts(), getSalesOpportunities(), getSalesOrders() to return lists of entity objects. Purchasing initially will just have search of the suppliers and orders domain to getSuppliers() and getPurchaseOrders().

Implementing search this way makes it easier to replace one search technology with another. For example, one day we may have a document management domain in opentaps, and there could be a DocumentSearchServiceInterface in this domain. This interface might specify that for a set of keywords, it will return a List<Document> of Document objects which might have the names, summaries, and links to the actual documents. In one implementation, we might use the Google Search Appliance to implement the DocumentDomainSearchInterface, but in another instance, we could use a different document indexing and search tool. Applications such as CRM and purchasing could then call on the document domain to search for documents, while being separated from the actual implementation of the indexing and search.

Configuration

The indexing of entities for search is configured by hot-deploy/opentaps-common/config/entitysearch.properties. You can configure an entity to be indexed:

SalesOpportunity = index

And you can also configure the weights of the entity's fields:

SalesOpportunity.salesOpportunityId = 1
SalesOpportunity.opportunityName = 10
SalesOpportunity.description = 1
SalesOpportunity.nextStep = 1

Sometimes you'll have to index entities such as SalesOpportunityRole or PartyRole, so that the search services can use them to determine the type of party and whether it is an account, contact, or lead.

Note that view entities can not be indexed, since they are not actually stored in the database.

Integration with Persistence Layer

Because we are using hibernate search, data stored with hibernate will automatically be indexed.

For data stored using the ofbiz entity engine, opentaps uses aspect oriented programming (AOP) to intercept the ofbiz delegator's Entity-Event-Condition-Action (EECA) sequence. Normally, after the delegator stores a value, it will evaluate EECA's attached to the entity to see if any services should be run. opentaps has added an aspect to the ofbiz delegator, so that it will also index the entity stored.

Displaying Search Results

The results of the search should be passed to our GWT EntityListViews so that the webapps could display them.

Clearing Search Indices

The hibernate search index files are located in runtime/lucene/indexes (this is defined in org.opentaps.domain.container.HibernateCfgGeneratorContainer.java) and can be cleared by

$ ant refresh

After clearing them, you will need to run the opentaps.createHibernateSearchIndex service again to re-build them.