On 05/25/2012 04:48 PM, savitha sundaramurthy wrote:
Hi all,
I have come up with some basic set of API's for Solr search component.
I have made it generic such that it can use solr or lucene as the backend.
I have also documented in the DEsign proposal.
http://dev.xwiki.org/xwiki/bin/view/Design/SOLRSearchIntegration
*getBackend*
public String getBackend()
*Returns:*
Returns the name of the backend which is currently in use. It could be
Lucene or Solr.
Not only, it could be internal Solr, remote Solr, internal Lucene,
distributed Lucene.
I'm not convinced this method is useful/needed.
*rebuildIndex*
*
*
*public int rebuildIndex(com.xpn.xwiki.api.XWiki wiki,
com.xpn.xwiki.api.Context context)*
Starts the rebuild of the whole index
*Parameters:*
wiki
context
*Returns:*
Number of documents scheduled for indexing. -1 in case of errors
Using the XWiki and XWikiContext classes is not encouraged, since these
are old APIs being replaced by components. The method shouldn't receive
any of these parameters, and it should get access to the needed
components as injected dependencies.
However, there are other parameters that could be useful, specifying
what to index, although I'd rather use different methods:
* public int rebuildFarmIndex() rebuilds the index for the whole wiki farm
* public int rebuildWikiIndex() rebuilds the index for the current wiki
* public int indexDocuments(List<DocumentReference> documents) reindexes
the given set of documents
*
*
*getSearchResults*
*
*
*
*
*
*
*
*
public searchResponse *getSearchResults*(java.lang.String query,
java.lang.string languages,
com.xpn.xwiki.api.XWiki wiki)
Searches the configured Indexes using the specified query for documents in
the given languages.
With virtual wikis enabled in your xwiki installation this will deliver
results from all virtuall wikis.
*Parameters : *
query - query string given by the user
languages - comma separated list of language codes to search in, may be
null to search all languages. Language codes can be:
- default for content having no specific language information
- lower case 2- letter language codes like en, es , fr.
*Returns:*
a searchResponse instance containing the results (i.e) the response objects.
Again, the XWiki parameter shouldn't be there.
I'd rather call the method "search" instead of
"getSearchResults".
Instead of a comma separated list of languages, I'd rather use a
List<String>.
I'm not sure that by default results should come from all wikis. Let's
leave it as you proposed for the moment, and we'll think about it later.
*getSearchResults*
public searchResponse *getSearchResults*(java.lang.String query,
java.lang.String
virtualWikiNames
java.lang.string
languages,
com.xpn.xwiki.api.XWiki
wiki)
Searches the configured Indexes using the specified query for documents in
the given languages belonging to one of the given virtual wikis.
*Parameters : *
query - query string given by the user
languages - comma separated list of language codes to search in, may be
null to search all languages. Language codes can be:
- default for content having no specific language information
- lower case 2- letter language codes like en, es , fr.
virtualWikiNames - Names of the virtual wikis to search in. May be null for
global search.
*Returns:*
a searchResponse instance containing the results (i.e) the response objects.
Again, no XWiki parameter, and List<String> instead of String.
I'm not sure on whether to expose the startIndex as API
Yes, offset and limit should be part of the APIs.
*Admin Module:*
*
*
I has some thoughts on API's for admin settings where one could check the
precision and recall results based on some known documents and could tweak
the boost values accordingly.
That's for later, let's start with the search first.
Thanking you,
Savitha.
--
Sergiu Dumitriu
http://purl.org/net/sergiu/