Author: daniele
Date: 2007-04-23 15:39:48 +0200 (Mon, 23 Apr 2007)
New Revision: 4852

Modified:
   
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/command/CatalogueSearchCommand.java
Log:
SEARCH-2085: keyword rank profile is standard if no company name is found in 
search term.

Modified: 
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/command/CatalogueSearchCommand.java
===================================================================
--- 
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/command/CatalogueSearchCommand.java
  2007-04-23 12:20:51 UTC (rev 4851)
+++ 
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/command/CatalogueSearchCommand.java
  2007-04-23 13:39:48 UTC (rev 4852)
@@ -70,7 +70,10 @@
  */
 public final class CatalogueSearchCommand extends AdvancedFastSearchCommand {
 
-    private boolean sortBy=false;
+    /** Yet another field that contain the result from text analysis and
+     *  which rank profile to use if there are keyword terms or company name 
terms.
+     */
+    private String analysisSortBy;
     
     /** Logger for this class. */
     private static final Logger LOG = 
Logger.getLogger(CatalogueSearchCommand.class);
@@ -299,7 +302,7 @@
         getParameters().put(PARAMETER_NAME_WHAT, 
getTransformedQuerySesamSyntax());
         getParameters().put(PARAMETER_NAME_WHERE, whereString);
 
-        getParameters().put("userSortBy",userSortBy);
+        getParameters().put("analysisSortBy",analysisSortBy);
         return result;
     }
 
@@ -358,7 +361,9 @@
      * which rank-profile to sort by.
      *
      * The sorting may be altered if user has supplied the userSortBy
-     * parameter.
+     * parameter or if user has not supplied any sorting, the text analysis
+     * overides the specified sorting from modes.xml
+     * 
      * @return the sorting to be used when executing the query.
      */
     @Override
@@ -366,11 +371,11 @@
         String sortBy = super.getSortBy();
         if ("name".equalsIgnoreCase(userSortBy)) {
             sortBy = SORTBY_COMPANYNAME;
-        }else{
-            if(this.sortBy) sortBy=SORTBY_COMPANYNAME;
-            else sortBy=SORTBY_KEYWORD;
         }
         
+        if(userSortBy==null && analysisSortBy!=null)
+            sortBy = analysisSortBy;
+        
 
         return sortBy;
     }
@@ -413,12 +418,14 @@
         final boolean hasNotWordCharacters = m.find();
 
 
-        
if(clause.getKnownPredicates().contains(TokenPredicate.COMPANYENRICHMENT)
-           && (userSortBy==null || !userSortBy.equalsIgnoreCase("name"))){
-            userSortBy = "name";
+        if(clause.getKnownPredicates().contains(TokenPredicate.COMPANY_KEYWORD)
+                && analysisSortBy==null){
+            analysisSortBy = SORTBY_KEYWORD;
+        }else 
if(clause.getKnownPredicates().contains(TokenPredicate.COMPANYENRICHMENT)
+                && analysisSortBy==null){
+             analysisSortBy = SORTBY_COMPANYNAME;
         }
             
-            
 
         if(hasNotWordCharacters){
             appendToQueryRepresentation(createPhraseQuerySyntax('\"' + 
getTransformedTerms().get(clause) + '\"'));

_______________________________________________
Kernel-commits mailing list
[email protected]
http://sesat.no/mailman/listinfo/kernel-commits

Reply via email to