public SearchEngineQueryBuilder.SearchEngineMoreLikeThisQueryBuilder setProperties(String[] properties) { propertiesSet = true; moreLikeThis.setFieldNames(properties); return this; }
public void setFieldNames(String[] fieldNames) { moreLikeThis.setFieldNames(fieldNames); }
public SearchEngineQueryBuilder.SearchEngineMoreLikeThisQueryBuilder addProperty(String property) { propertiesSet = true; if (moreLikeThis.getFieldNames() == null) { moreLikeThis.setFieldNames(new String[]{property}); } else { String[] newNames = new String[moreLikeThis.getFieldNames().length + 1]; System.arraycopy(moreLikeThis.getFieldNames(), 0, newNames, 0, moreLikeThis.getFieldNames().length); newNames[newNames.length -1] = property; moreLikeThis.setFieldNames(newNames); } return this; }
private void init(LuceneSearchEngine searchEngine, LuceneSearchEngineFactory searchEngineFactory) { this.searchEngine = searchEngine; this.searchEngineFactory = searchEngineFactory; LuceneSearchEngineInternalSearch internalSearch = (LuceneSearchEngineInternalSearch) searchEngine.internalSearch(subIndexes, aliases); this.moreLikeThis = new MoreLikeThis(internalSearch.getReader()); this.moreLikeThis.setFieldNames(null); this.moreLikeThis.setAnalyzer(searchEngine.getSearchEngineFactory().getAnalyzerManager().getSearchAnalyzer()); }
public SearchEngineQuery toQuery() { if (!propertiesSet) { moreLikeThis.setFieldNames(new String[]{searchEngine.getSearchEngineFactory().getAllProperty()}); } try { Query query; if (reader != null) { query = moreLikeThis.like(reader); } else { BooleanQuery boolQuery = new BooleanQuery(); boolQuery.add(moreLikeThis.like(resource.getDocNum()), BooleanClause.Occur.MUST); boolQuery.add(ResourceHelper.buildResourceLoadQuery(resource.getResourceKey()), BooleanClause.Occur.MUST_NOT); query = boolQuery; } return new LuceneSearchEngineQuery(searchEngineFactory, query); } catch (IOException e) { throw new SearchEngineException("Failed to find queries like [" + idResource + "]", e); } }
private void copy(MoreLikeThis moreLikeThis) { moreLikeThis.setAnalyzer(this.moreLikeThis.getAnalyzer()); moreLikeThis.setBoost(this.moreLikeThis.isBoost()); moreLikeThis.setFieldNames(this.moreLikeThis.getFieldNames()); moreLikeThis.setMaxNumTokensParsed(this.moreLikeThis.getMaxNumTokensParsed()); moreLikeThis.setMaxQueryTerms(this.moreLikeThis.getMaxQueryTerms()); moreLikeThis.setMaxWordLen(this.moreLikeThis.getMaxWordLen()); moreLikeThis.setMinDocFreq(this.moreLikeThis.getMinDocFreq()); moreLikeThis.setMinTermFreq(this.moreLikeThis.getMinTermFreq()); moreLikeThis.setMinWordLen(this.moreLikeThis.getMinWordLen()); moreLikeThis.setStopWords(this.moreLikeThis.getStopWords()); } }
public MoreLikeThisHelper( SolrParams params, SolrIndexSearcher searcher ) { this.searcher = searcher; this.reader = searcher.getReader(); this.uniqueKeyField = searcher.getSchema().getUniqueKeyField(); this.needDocSet = params.getBool(FacetParams.FACET,false); SolrParams required = params.required(); String[] fields = splitList.split( required.get(MoreLikeThisParams.SIMILARITY_FIELDS) ); if( fields.length < 1 ) { throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "MoreLikeThis requires at least one similarity field: "+MoreLikeThisParams.SIMILARITY_FIELDS ); } this.mlt = new MoreLikeThis( reader ); // TODO -- after LUCENE-896, we can use , searcher.getSimilarity() ); mlt.setFieldNames(fields); mlt.setAnalyzer( searcher.getSchema().getAnalyzer() ); // configurable params mlt.setMinTermFreq( params.getInt(MoreLikeThisParams.MIN_TERM_FREQ, MoreLikeThis.DEFAULT_MIN_TERM_FREQ)); mlt.setMinDocFreq( params.getInt(MoreLikeThisParams.MIN_DOC_FREQ, MoreLikeThis.DEFAULT_MIN_DOC_FREQ)); mlt.setMinWordLen( params.getInt(MoreLikeThisParams.MIN_WORD_LEN, MoreLikeThis.DEFAULT_MIN_WORD_LENGTH)); mlt.setMaxWordLen( params.getInt(MoreLikeThisParams.MAX_WORD_LEN, MoreLikeThis.DEFAULT_MAX_WORD_LENGTH)); mlt.setMaxQueryTerms( params.getInt(MoreLikeThisParams.MAX_QUERY_TERMS, MoreLikeThis.DEFAULT_MAX_QUERY_TERMS)); mlt.setMaxNumTokensParsed(params.getInt(MoreLikeThisParams.MAX_NUM_TOKENS_PARSED, MoreLikeThis.DEFAULT_MAX_NUM_TOKENS_PARSED)); mlt.setBoost( params.getBool(MoreLikeThisParams.BOOST, false ) ); boostFields = SolrPluginUtils.parseFieldBoosts(params.getParams(MoreLikeThisParams.QF)); }