[Building Sakai] Sakai Search Tool 2.6

jupiter.user sumathymanoharan at gmail.com
Tue Jul 19 23:09:37 PDT 2011


Hi Zhen,

Currently I am working on this sorting feature.  Thanks for the solution you
have provided.  I had followed your instruction and changed the indexSorter
in BaseSearchServiceImpl.java but it does not have any effect on the search
results.

Also I had directly changed new Sort("tool"); to new Sort("title") in
BaseSearchServiceImpl.java. It can be compiled but when I check the search
result, there is no change in the sort order.

Can you please guide me where I am going wrong?  

[code]
				IndexSearcher indexSearcher = getIndexSearcher(false);
				if (indexSearcher != null)
				{
					Hits h = null;
					Filter indexFilter = (Filter) luceneFilters.get(filterName);



					Sort indexSorter = (Sort) luceneSorters.get(sorterName);
					//new Sort("tool");
					new Sort("title");
					if (log.isDebugEnabled())
					{
						log.debug("Using Filter " + filterName + ":" //$NON-NLS-1$
//$NON-NLS-2$
								+ indexFilter + " and " + sorterName + ":" //$NON-NLS-1$
//$NON-NLS-2$
								+ indexSorter);
					}
					if (indexFilter != null && indexSorter != null)
					{
						h = indexSearcher.search(query, indexFilter, indexSorter);
					}
					else if (indexFilter != null)
					{
						h = indexSearcher.search(query, indexFilter);
					}
					else if (indexSorter != null)
					{
						h = indexSearcher.search(query, indexSorter);
					}
					else
					{
						h = indexSearcher.search(query);
					}
					if (log.isDebugEnabled())
					{
						log.debug("Got " + h.length() + " hits"); //$NON-NLS-1$ //$NON-NLS-2$
					}
					eventTrackingService.post(eventTrackingService.newEvent(EVENT_SEARCH,
							EVENT_SEARCH_REF + textQuery.toString(), true,
							NotificationService.PREF_IMMEDIATE));
					return new SearchListImpl(h, textQuery, start, end, 
							getAnalyzer(), filter, searchIndexBuilder, this);[/code]



Hi, Amy:

Collecting all search result and sort then outside search engine is one way
to accomplish the task. However, doing so might introduce performance
problem if the returning result is of big list.

Before Lucene 1.4, search results were only returned in descending relevance
score  order. Sakai search tool is based on Lucence 2.9 (as of Sakai 2.7),
so we are likely to leverage Lucene's inner sorting capabilities by doing
the following steps:

1. Note that currently Sakai entities are indexed with the following fields
populated: "siteid", "url", "tool", "title", "contents", "context",
"subtype", "type", "id", "container", "reference", "digestCount". The field
definition is inside SearchService.java. You can select subset of the list
as search sort choices in Search tool, add the sort filter to search
interface, I think it is the index.vm file, so that user can select the sort
criteria. 

2. Modify search() inside SearchBeanImpl.java, so that you can set the
sortName attribute to based user's selection of sort criteria;

3. Check search() inside BaseSearchServiceImpl.java, make sure the
indexSorter field is setup correctly for sort. So if you are sorting based
on title, the indexSorter should be constructed as new Sort("title").

And now you can search and sort!

HTH,

- Zhen

-- 
View this message in context: http://old.nabble.com/-Building-Sakai--Sakai-Search-Tool-2.6-tp31961196p32096739.html
Sent from the Sakai - Development mailing list archive at Nabble.com.



More information about the sakai-dev mailing list