mirror of
https://github.com/yacy/yacy_search_server.git
synced 2024-09-19 00:01:41 +02:00
using the search filter to drill down search to file types.
A search like "mp3 filetype:mp3" will now maybe surprise you.
This commit is contained in:
parent
bc865ab816
commit
fb9460f0a8
|
@ -193,15 +193,14 @@ public class Segment {
|
||||||
return this.termIndex.getBufferSize();
|
return this.termIndex.getBufferSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getQueryCount(String word) {
|
public int getQueryCount(StringBuilder wordsb) {
|
||||||
int count = this.termIndex == null ? 0 : this.termIndex.count(Word.word2hash(word));
|
return getQueryCount(wordsb.toString());
|
||||||
try {count += this.fulltext.getSolr().getQueryCount(YaCySchema.text_t.name() + ':' + word);} catch (IOException e) {}
|
|
||||||
return count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getQueryCount(StringBuilder word) {
|
public int getQueryCount(String word) {
|
||||||
|
if (word == null || word.indexOf(':') >= 0 || word.indexOf(' ') >= 0) return 0;
|
||||||
int count = this.termIndex == null ? 0 : this.termIndex.count(Word.word2hash(word));
|
int count = this.termIndex == null ? 0 : this.termIndex.count(Word.word2hash(word));
|
||||||
try {count += this.fulltext.getSolr().getQueryCount(YaCySchema.text_t.name() + ':' + word.toString());} catch (IOException e) {}
|
try {count += this.fulltext.getSolr().getQueryCount(YaCySchema.text_t.name() + ':' + word);} catch (IOException e) {}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -467,7 +467,12 @@ public final class QueryParams {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
final static String[] fields = new String[]{"sku","title","h1_txt","h2_txt","author","description","keywords","text_t"};
|
final static String[] fields = new String[]{
|
||||||
|
YaCySchema.sku.name(),YaCySchema.title.name(),
|
||||||
|
YaCySchema.h1_txt.name(),YaCySchema.h2_txt.name(),
|
||||||
|
YaCySchema.author.name(),YaCySchema.description.name(),
|
||||||
|
YaCySchema.keywords.name(),YaCySchema.text_t.name()
|
||||||
|
};
|
||||||
|
|
||||||
public String solrQueryString(boolean urlencoded) {
|
public String solrQueryString(boolean urlencoded) {
|
||||||
if (this.query_include_words == null || this.query_include_words.size() == 0) return null;
|
if (this.query_include_words == null || this.query_include_words.size() == 0) return null;
|
||||||
|
@ -486,15 +491,19 @@ public final class QueryParams {
|
||||||
w.append(s);
|
w.append(s);
|
||||||
wc++;
|
wc++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// combine these queries for all relevant fields
|
||||||
wc = 0;
|
wc = 0;
|
||||||
for (String a: fields) {
|
for (String a: fields) {
|
||||||
if (wc > 0) q.append(urlencoded ? "+OR+" : " OR ");
|
if (wc > 0) q.append(urlencoded ? "+OR+" : " OR ");
|
||||||
q.append('(').append(a).append(':').append(w).append(')');
|
q.append('(').append(a).append(':').append(w).append(')');
|
||||||
wc++;
|
wc++;
|
||||||
}
|
}
|
||||||
|
q.insert(0, '(');
|
||||||
|
q.append(')');
|
||||||
|
|
||||||
// add filter to prevent that results come from failed urls
|
// add filter to prevent that results come from failed urls
|
||||||
q.append(urlencoded ? "+-failreason_t:[*+TO+*]" : " -failreason_t:[* TO *]");
|
q.append(urlencoded ? "+AND+-failreason_t:[*+TO+*]" : " AND -failreason_t:[* TO *]");
|
||||||
|
|
||||||
// add constraints
|
// add constraints
|
||||||
if ( this.sitehash == null ) {
|
if ( this.sitehash == null ) {
|
||||||
|
@ -506,6 +515,12 @@ public final class QueryParams {
|
||||||
} else {
|
} else {
|
||||||
q.append(urlencoded ? "+host_id_s:" : " host_id_s:").append(this.sitehash);
|
q.append(urlencoded ? "+host_id_s:" : " host_id_s:").append(this.sitehash);
|
||||||
}
|
}
|
||||||
|
String urlMaskPattern = this.urlMask.pattern();
|
||||||
|
int extm = urlMaskPattern.indexOf(".*\\.");
|
||||||
|
if (extm >= 0) {
|
||||||
|
String ext = urlMaskPattern.substring(extm + 4);
|
||||||
|
q.append(urlencoded ? "+AND+url_file_ext_s:" : " AND url_file_ext_s:").append(ext);
|
||||||
|
}
|
||||||
|
|
||||||
if (this.radius > 0.0d && this.lat != 0.0d && this.lon != 0.0d) {
|
if (this.radius > 0.0d && this.lat != 0.0d && this.lon != 0.0d) {
|
||||||
// localtion search, no special ranking
|
// localtion search, no special ranking
|
||||||
|
|
Loading…
Reference in New Issue
Block a user