Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
add patch which shall prevent that naive search mistakes like usage of regular expressions cause no results. Usage of '*' followed by a dot or any expression will now cause that this expression is used as a filetype search.
Michael Peter Christen25f9c350335c
diff --git a/htroot/yacysearch.java b/htroot/yacysearch.javaindex adb16d9e5..f2a577ef3 100644--- a/htroot/yacysearch.java+++ b/htroot/yacysearch.java@@ -370,7 +370,12 @@ public class yacysearch {int stp = querystring.indexOf('*');if (stp >= 0) {- querystring = querystring.substring(0, stp) + Segment.catchallString + querystring.substring(stp + 1);+ // if the star appears as a single entry, use the catchallstring+ if (querystring.length() == 1) {+ querystring = Segment.catchallString;+ } else {+ querystring = querystring.replace('*', ' ').replaceAll(" ", " ");+ }}if ( querystring.indexOf("/near", 0) >= 0 ) {querystring = querystring.replace("/near", "");diff --git a/source/net/yacy/search/query/QueryModifier.java b/source/net/yacy/search/query/QueryModifier.javaindex 362ece108..d17871348 100644--- a/source/net/yacy/search/query/QueryModifier.java+++ b/source/net/yacy/search/query/QueryModifier.java@@ -27,6 +27,7 @@ import org.apache.solr.common.params.MultiMapSolrParams;import net.yacy.cora.document.id.DigestURL;import net.yacy.cora.util.CommonPattern;+import net.yacy.search.index.Segment;import net.yacy.search.schema.CollectionSchema;import net.yacy.server.serverObjects;@@ -74,21 +75,11 @@ public class QueryModifier {add("/file");}+ // parse 'common search mistakes' like guessed regular expressions+ querystring = filetypeParser(querystring, "*");+// parse filetype- final int ftp = querystring.indexOf("filetype:", 0);- if ( ftp >= 0 ) {- int ftb = querystring.indexOf(' ', ftp);- if ( ftb == -1 ) {- ftb = querystring.length();- }- filetype = querystring.substring(ftp + 9, ftb);- querystring = querystring.replace("filetype:" + filetype, "");- while ( !filetype.isEmpty() && filetype.charAt(0) == '.' ) {- filetype = filetype.substring(1);- }- add("filetype:" + filetype);- if (filetype.isEmpty()) filetype = null;- }+ querystring = filetypeParser(querystring, "filetype:");// parse sitefinal int sp = querystring.indexOf("site:", 0);@@ -141,6 +132,23 @@ public class QueryModifier {return querystring.trim();}+ private String filetypeParser(String querystring, final String filetypePrefix) {+ final int ftp = querystring.indexOf(filetypePrefix, 0);+ if ( ftp >= 0 ) {+ int ftb = querystring.indexOf(' ', ftp);+ if ( ftb < 0 ) ftb = querystring.length();+ filetype = querystring.substring(ftp + filetypePrefix.length(), ftb);+ querystring = querystring.replace(filetypePrefix + filetype, "");+ while ( !filetype.isEmpty() && filetype.charAt(0) == '.' ) {+ filetype = filetype.substring(1);+ }+ add("filetype:" + filetype);+ if (filetype.isEmpty()) filetype = null;+ if (querystring.length() == 0) querystring = "*";+ }+ return querystring;+ }+public void add(String m) {if (modifier.length() > 0 && modifier.charAt(modifier.length() - 1) != ' ' && m != null && m.length() > 0) modifier.append(' ');if (m != null) modifier.append(m);