From c7c291bc6b91ee1c570d3d808ba8f3685d3b1762 Mon Sep 17 00:00:00 2001 From: lotus Date: Mon, 12 Jan 2009 14:59:27 +0000 Subject: [PATCH] allow simultaneous inurl: site: and filetype: search git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5478 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/index.html | 2 +- htroot/yacysearch.java | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/htroot/index.html b/htroot/index.html index 9f0dbb4e5..7fdde0a62 100644 --- a/htroot/index.html +++ b/htroot/index.html @@ -27,7 +27,7 @@ - +
   diff --git a/htroot/yacysearch.java b/htroot/yacysearch.java index e36dd4e4a..c2003939a 100644 --- a/htroot/yacysearch.java +++ b/htroot/yacysearch.java @@ -119,17 +119,15 @@ public class yacysearch { } // collect search attributes + boolean newsearch = post.hasValue("query") && post.hasValue("former") && !post.get("query","").equalsIgnoreCase(post.get("former","")); //new search term + int itemsPerPage = Math.min((authenticated) ? 1000 : 10, post.getInt("maximumRecords", post.getInt("count", 10))); // SRU syntax with old property as alternative - int offset = (post.hasValue("query") && post.hasValue("former") && !post.get("query","").equalsIgnoreCase(post.get("former",""))) ? 0 : post.getInt("startRecord", post.getInt("offset", 0)); + int offset = (newsearch) ? 0 : post.getInt("startRecord", post.getInt("offset", 0)); boolean global = (post == null) ? true : post.get("resource", "global").equals("global"); final boolean indexof = (post != null && post.get("indexof","").equals("on")); + String urlmask = ""; - if (post != null && post.containsKey("urlmask") && post.get("urlmask").equals("no")) { - urlmask = ".*"; - } else { - urlmask = (post != null && post.containsKey("urlmaskfilter")) ? (String) post.get("urlmaskfilter") : ".*"; - } String prefermask = (post == null ? "" : post.get("prefermaskfilter", "")); if ((prefermask.length() > 0) && (prefermask.indexOf(".*") < 0)) prefermask = ".*" + prefermask + ".*"; @@ -234,7 +232,7 @@ public class yacysearch { String ft = querystring.substring(filetype + 9, ftb); query[0].remove("filetype:" + ft.toLowerCase()); while(ft.startsWith(".")) ft = ft.substring(1); - if(ft.length() > 0) urlmask = ".*\\." + ft; + if(ft.length() > 0) urlmask = urlmask + ".*\\." + ft; } int site = querystring.indexOf("site:"); if (site >= 0) { @@ -244,8 +242,15 @@ public class yacysearch { query[0].remove("site:" + domain.toLowerCase()); while(domain.startsWith(".")) domain = domain.substring(1); if (domain.indexOf(".") < 0) domain = "\\." + domain; // is tld - if (domain.length() > 0) urlmask = "[a-zA-Z]*://[^/]*" + domain + "/.*"; + if (domain.length() > 0) urlmask = "[a-zA-Z]*://[^/]*" + domain + "/.*" + urlmask; + } + if (urlmask.length() == 0 && post != null && post.containsKey("urlmask") && post.get("urlmask").equals("no")) { // option search all + urlmask = ".*"; + } else if (urlmask.length() == 0 && !newsearch && post.containsKey("urlmaskfilter")) { + final String purlmaskfilter = post.get("urlmaskfilter", ".*"); + if(!purlmaskfilter.equals(".*")) urlmask = purlmaskfilter; } + if(urlmask.length() == 0) urlmask = ".*"; //if no urlmask was given // read the language from the language-restrict option 'lr' // if no one is given, use the user agent or the system language as default