mirror of
https://github.com/yacy/yacy_search_server.git
synced 2024-09-19 00:01:41 +02:00
added language selection to search query:
- the language can be selected using a LANGUAGE:<language> element in the query line, i.e.: java LANGUAGE:en - the language can be selected with a post element in google-style syntax with the 'rl' element: ?lr=lang_en&query=java git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5193 6c8d7289-2bf4-0310-a012-ef5d649a1542
This commit is contained in:
parent
00c1535f84
commit
1198eeecc7
|
@ -138,11 +138,6 @@ public class yacysearch {
|
|||
constraint.set(plasmaCondenser.flag_cat_indexof, true);
|
||||
}
|
||||
|
||||
// find out language of the user by reading of the user-agent string
|
||||
String agent = header.get("User-Agent");
|
||||
if (agent == null) agent = System.getProperty("user.language");
|
||||
String language = (agent == null) ? "en" : iso639.userAgentLanguageDetection(agent);
|
||||
|
||||
// SEARCH
|
||||
//final boolean indexDistributeGranted = sb.getConfig(plasmaSwitchboard.INDEX_DIST_ALLOW, "true").equals("true");
|
||||
//final boolean indexReceiveGranted = sb.getConfig("allowReceiveIndex", "true").equals("true");
|
||||
|
@ -203,7 +198,24 @@ public class yacysearch {
|
|||
query[0].remove("recent");
|
||||
ranking.coeff_date = plasmaSearchRankingProfile.COEFF_MAX;
|
||||
}
|
||||
int lrp = querystring.indexOf("LANGUAGE:");
|
||||
String lr = "";
|
||||
if (lrp >= 0) {
|
||||
lr = querystring.substring(lrp + 9, lrp + 11).toLowerCase();
|
||||
query[0].remove("language:" + lr);
|
||||
}
|
||||
|
||||
// read the language from the language-restrict option 'lr'
|
||||
// if no one is given, use the user agent or the system language as default
|
||||
String language = (post == null) ? lr : post.get("lr", lr);
|
||||
if (language.startsWith("lang_")) language = language.substring(5);
|
||||
if (!iso639.exists(language)) {
|
||||
// find out language of the user by reading of the user-agent string
|
||||
String agent = header.get("User-Agent");
|
||||
if (agent == null) agent = System.getProperty("user.language");
|
||||
language = (agent == null) ? "en" : iso639.userAgentLanguageDetection(agent);
|
||||
}
|
||||
|
||||
int maxDistance = (querystring.indexOf('"') >= 0) ? maxDistance = query.length - 1 : Integer.MAX_VALUE;
|
||||
|
||||
// filter out stopwords
|
||||
|
|
|
@ -231,7 +231,7 @@ public final class plasmaSearchQuery {
|
|||
return kelondroMSetTools.anymatch(wordhashes, keyhashes);
|
||||
}
|
||||
|
||||
private static String seps = "'.,:/&"; static {seps += '"';}
|
||||
private static String seps = "'.,/&-_"; static {seps += '"';}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static TreeSet<String>[] cleanQuery(String querystring) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user