Author: ssmiweve
Date: 2007-05-31 20:39:14 +0200 (Thu, 31 May 2007)
New Revision: 5238
Modified:
branches/2.13/core-api/src/main/java/no/schibstedsok/searchportal/mode/command/CatalogueSearchCommand.java
branches/2.13/query-api/src/main/java/no/schibstedsok/searchportal/query/token/TokenPredicate.java
Log:
SEARCH-2653 - tlf "bedriftsnavn" returnerer 1 016 685 i antall treff
SEARCH-2085 - Bruke tekstanalysen til aa bestemme hvilken rankprofil vi skal
bruke
COMPANYRANK is not used by anybody
Modified:
branches/2.13/core-api/src/main/java/no/schibstedsok/searchportal/mode/command/CatalogueSearchCommand.java
===================================================================
---
branches/2.13/core-api/src/main/java/no/schibstedsok/searchportal/mode/command/CatalogueSearchCommand.java
2007-05-30 20:27:06 UTC (rev 5237)
+++
branches/2.13/core-api/src/main/java/no/schibstedsok/searchportal/mode/command/CatalogueSearchCommand.java
2007-05-31 18:39:14 UTC (rev 5238)
@@ -79,8 +79,8 @@
/** boolean flags to which get set during visitor pass.
* used by getSortBy to determin which rank profile to use.
*/
- private boolean foundCompanyNameInQuery=false;
- private boolean foundKeywordInQuery=false;
+ private Boolean whoQueryIsCompanyName = null;
+ private Boolean whoQueryIsKeyword = null;
/** Logger for this class. */
private static final Logger LOG =
Logger.getLogger(CatalogueSearchCommand.class);
@@ -260,7 +260,6 @@
}
/**
- * Todo: Javadoc.
*/
@Override
protected Query getQuery(){
@@ -269,7 +268,6 @@
}
/**
- * Todo: Javadoc.
*/
@Override
protected TokenEvaluationEngine getEngine(){
@@ -410,19 +408,19 @@
*/
@Override
protected String getSortBy() {
- String sortBy = super.getSortBy();
- sortBy =
foundKeywordInQuery?SORTBY_KEYWORD:foundCompanyNameInQuery?SORTBY_COMPANYNAME:sortBy;
+ final String sortBy;
if ("name".equalsIgnoreCase(userSortBy)) {
sortBy = SORTBY_COMPANYNAME;
}else if("kw".equalsIgnoreCase(userSortBy)){
sortBy = SORTBY_KEYWORD;
- }
-
- final ParametersDataObject pdo = datamodel.getParameters();
- if(GeoSearchUtil.isGeoSearch(pdo)){
+ }else if(GeoSearchUtil.isGeoSearch(datamodel.getParameters())){
sortBy="iypgeosortable";
+ }else{
+ sortBy = whoQueryIsKeyword
+ ? SORTBY_KEYWORD
+ : whoQueryIsCompanyName ? SORTBY_COMPANYNAME :
super.getSortBy();
}
return sortBy;
}
@@ -464,18 +462,9 @@
final boolean hasNotWordCharacters = m.find();
- // check if this is a known keyword.
-
if(clause.getKnownPredicates().contains(TokenPredicate.COMPANY_KEYWORD)){
- foundKeywordInQuery=true;
- }
-
- // check if this is a known company name.
- if(clause.getKnownPredicates().contains(TokenPredicate.COMPANYRANK)
- ||
clause.getKnownPredicates().contains(TokenPredicate.COMPANYENRICHMENT)){
-
- foundCompanyNameInQuery=true;
- }
-
+ checkQueryForKeyword(clause);
+ checkQueryForCompanyname(clause);
+
if(hasNotWordCharacters){
appendToQueryRepresentation(createPhraseQuerySyntax('\"' +
transformedTerm + '\"'));
@@ -550,6 +539,9 @@
* @param clause the clause to process.
*/
protected void visitImpl(final PhraseClause clause) {
+
+ checkQueryForKeyword(clause);
+ checkQueryForCompanyname(clause);
if (!BLANK.equals(getTransformedTerms().get(clause))) {
@@ -559,27 +551,49 @@
/**
* [EMAIL PROTECTED]
- * Todo: Javadoc
*/
@Override
protected void visitImpl(final DefaultOperatorClause clause) {
+
+ checkQueryForKeyword(clause);
+ checkQueryForCompanyname(clause);
- appendToQueryRepresentation('(');
+ final int originalLength = getQueryRepresentationLength();
+
clause.getFirstClause().accept(this);
- final int queryRepLength = getQueryRepresentationLength();
+ final int firstClauseLength = getQueryRepresentationLength();
-
clause.getSecondClause().accept(this);
+ final int secondClauseLength = getQueryRepresentationLength();
- final boolean queryRepGrown = queryRepLength > 0 &&
getQueryRepresentationLength() > queryRepLength;
+ final boolean queryRepGrown = firstClauseLength > 0 &&
secondClauseLength > firstClauseLength;
if(queryRepGrown && !(clause.getSecondClause() instanceof NotClause)){
// we know the query representation got longer which means we need
to insert the operator
- insertToQueryRepresentation(queryRepLength, QL_AND);
+ insertToQueryRepresentation(firstClauseLength, QL_AND);
}
- appendToQueryRepresentation(')');
+ if(secondClauseLength > originalLength){
+ insertToQueryRepresentation(originalLength, "(");
+ appendToQueryRepresentation(')');
+ }
}
+ private void checkQueryForKeyword(final Clause clause){
+
+ // check if this is a known keyword.
+ if(null == whoQueryIsKeyword){
+ whoQueryIsKeyword =
clause.getKnownPredicates().contains(TokenPredicate.COMPANY_KEYWORD);
+ }
+ }
+
+ private void checkQueryForCompanyname(final Clause clause){
+
+ // check if this is a known company name.
+ if(null == whoQueryIsCompanyName){
+ whoQueryIsCompanyName =
clause.getKnownPredicates().contains(TokenPredicate.COMPANYENRICHMENT);
+ }
+ }
+
/**
* Query builder for creating the geographic query.
*
Modified:
branches/2.13/query-api/src/main/java/no/schibstedsok/searchportal/query/token/TokenPredicate.java
===================================================================
---
branches/2.13/query-api/src/main/java/no/schibstedsok/searchportal/query/token/TokenPredicate.java
2007-05-30 20:27:06 UTC (rev 5237)
+++
branches/2.13/query-api/src/main/java/no/schibstedsok/searchportal/query/token/TokenPredicate.java
2007-05-31 18:39:14 UTC (rev 5238)
@@ -33,8 +33,8 @@
EXACT_COMPANYENRICHMENT (Type.FAST),
COMPANY_KEYWORD (Type.FAST),
COMPANY_KEYWORD_RESERVED (Type.FAST),
- COMPANYRANK (Type.FAST),
- EXACT_COMPANYRANK (Type.FAST),
+// COMPANYRANK (Type.FAST), // not used!
+// EXACT_COMPANYRANK (Type.FAST), // not used!
DISEASE (Type.FAST),
ENGLISHWORDS (Type.FAST),
GEOLOCAL (Type.FAST),
_______________________________________________
Kernel-commits mailing list
[email protected]
http://sesat.no/mailman/listinfo/kernel-commits