Author: ssmaeklu
Date: 2007-06-13 12:39:08 +0200 (Wed, 13 Jun 2007)
New Revision: 5316

Modified:
   
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/command/PicSearchCommand.java
Log:
Temporary code to allow product to experiment with flexible top level domain 
boost. SEARCH-1851

Modified: 
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/command/PicSearchCommand.java
===================================================================
--- 
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/command/PicSearchCommand.java
        2007-06-13 09:32:12 UTC (rev 5315)
+++ 
trunk/core-api/src/main/java/no/schibstedsok/searchportal/mode/command/PicSearchCommand.java
        2007-06-13 10:39:08 UTC (rev 5316)
@@ -40,6 +40,7 @@
             = 
"/query?ie=UTF-8&tldb={0}&filter={1}&custid={2}&version=2.6&thumbs={3}&q={4}&start={5}&site={6}";
 
     private String siteFilter;
+    private final StringBuilder tldb = new StringBuilder();
 
     /**
      * Creates a new command in given context.
@@ -73,9 +74,16 @@
             LOG.error(e);
         }
 
+        String topDomainBoost = "";
 
+        try {
+            topDomainBoost = URLEncoder.encode(tldb.length() > 0 ? 
tldb.toString() : psConfig.getCountry(), "utf-8");
+        } catch (UnsupportedEncodingException e) {
+            LOG.error(e);
+        }
+
         final String url = MessageFormat.format(REQ_URL_FMT,
-                psConfig.getCountry(),
+                topDomainBoost,
                 psConfig.getFilter(),
                 psConfig.getCustomerId(),
                 psConfig.getResultsToReturn(),
@@ -159,6 +167,17 @@
     protected void visitImpl(final LeafClause clause) {
         final PictureCommandConfig psConfig = (PictureCommandConfig) 
context.getSearchConfiguration();
 
+        // Temportary code to allow experimenting with the new picsearch API 
feature "flexible top level domain boost".
+        if (clause.getField() != null && "tldb".equals(clause.getField())) {
+            if (tldb.length() > 0) {
+                tldb.append(',');
+            }
+
+            tldb.append(clause.getTerm().replace('=', ':').replace("\"", ""));
+            return;
+        }
+        // End temporary code.
+
         // Do not care about site in query if a static site filter was 
specified in the configuaration.
         if (getFieldFilter(clause) != null && "".equals(siteFilter) && 
"site".equals(clause.getField())) {
             siteFilter = clause.getTerm();

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

Reply via email to