SchemaField keyField = rb.req.getSearcher().getSchema().getUniqueKeyField(); if (null != keyField) if (!returnFields.contains(keyField))
private SchemaField getSchemaField(String fieldName){ if(cachedFields.containsKey(fieldName)){ return cachedFields.get(fieldName); } SchemaField field = searcher.getSchema().getField(fieldName); cachedFields.put(fieldName, field); return field; }
public FieldValueCountCollapseCollector(SolrIndexSearcher searcher, String collapseField) { super(searcher); IndexSchema schema = searcher.getSchema(); collapseFieldType = schema.getField(collapseField).getType(); }
private AggregateCollapseCollector(Map<AggregateField, AggregateFunction> functions, SolrIndexSearcher searcher) { super(searcher); this.functions = functions; for (AggregateField aggregateField : functions.keySet()) { try { String fieldName = aggregateField.getFieldName(); fieldCaches.put(fieldName, FieldCache.DEFAULT.getStringIndex(searcher.getReader(), fieldName)); fieldTypes.put(fieldName, searcher.getSchema().getFieldType(fieldName)); } catch (IOException e) { throw new RuntimeException(e); } } }
/** * Builds a new iterator with the given data. * * @param searcher the Solr index searcher. * @param queryCommand the query command that will be submitted.static * @param sort the sort specs. * @param consumer the Graph event consumer that will be notified on relevant events. */ DeepPagingIterator( final SolrIndexSearcher searcher, final SolrIndexSearcher.QueryCommand queryCommand, final SortSpec sort, final GraphEventConsumer consumer) { this.searcher = searcher; this.queryCommand = queryCommand; this.sentCursorMark = new CursorMark(searcher.getSchema(), sort); this.queryCommand.setCursorMark(sentCursorMark); this.consumer = consumer; }
protected void checkFieldsInSchema(SolrIndexSearcher searcher, Collection<String> fields) throws SolrException { IndexSchema schema = searcher.getSchema(); for (String field : fields) { SchemaField sField = schema.getField(field); if (sField == null) { throw new SolrException(ErrorCode.BAD_REQUEST, "\"" + field + "\" is not in schema " + schema.getSchemaName()); } } }
SchemaField sf = searcher.getSchema().getField(field); FieldType ft = sf.getType();
public UnInvertedField(String field, SolrIndexSearcher searcher) throws IOException { this.field = field; this.ti = new TermIndex(field, TrieField.getMainValuePrefix(searcher.getSchema().getFieldType(field))); uninvert(searcher); }
private NamedList getListedTermCounts(String field, String termList) throws IOException { FieldType ft = searcher.getSchema().getFieldType(field); List<String> terms = StrUtils.splitSmart(termList, ",", true); NamedList res = new NamedList(); Term t = new Term(field); for (String term : terms) { String internal = ft.toInternal(term); int count = searcher.numDocs(new TermQuery(t.createTerm(internal)), base); res.add(term, count); } return res; }
protected NamedList getCollapseGroupResult(int docId, NamedList result) { String uniqueIdFieldname = searcher.getSchema().getUniqueKeyField().getName(); try { String schemaId = searcher.doc(docId).get(uniqueIdFieldname); NamedList collapseGroupResult = (NamedList) result.get(schemaId); if (collapseGroupResult == null) { collapseGroupResult = new NamedList(); result.add(schemaId, collapseGroupResult); } return collapseGroupResult; } catch (IOException e) { throw new RuntimeException(e); } } }
if (!factories.isEmpty()) { final TermSubQueryBuilder termSubQueryBuilder = new TermSubQueryBuilder(newSearcher.getSchema().getQueryAnalyzer(), cache); for (final RewriterFactory factory : factories) { for (final Term term: factory.getGenerableTerms()) {
public NamedList<DocList> getMoreLikeThese( DocList docs, int rows, int flags ) throws IOException { IndexSchema schema = searcher.getSchema(); NamedList<DocList> mlt = new SimpleOrderedMap<DocList>(); DocIterator iterator = docs.iterator(); while( iterator.hasNext() ) { int id = iterator.nextDoc(); DocListAndSet sim = getMoreLikeThis( id, 0, rows, null, null, flags ); String name = schema.printableUniqueKey( reader.document( id ) ); mlt.add(name, sim.docList); } return mlt; }
public NamedList getFieldCacheStats(String fieldName, String[] facet ) { FieldType ft = searcher.getSchema().getFieldType(fieldName); final FieldFacetStats[] finfo = new FieldFacetStats[facet.length]; for( String f : facet ) { ft = searcher.getSchema().getFieldType(f); try { si = FieldCache.DEFAULT.getStringIndex(searcher.getReader(), f);
LazyCompactor compactor = depProvider.compactor(ppc, req.getSearcher().getSchema()); LazyDocumentLoader documentLoader = depProvider.documentLoader(pageSize, req.getSearcher());
@Override public void process(ResponseBuilder rb) throws IOException { if(isEnabled(rb)){ long startTime = System.currentTimeMillis(); SolrParams params = rb.req.getParams(); int topN = getTopN(params); boolean binary = getBinary(params); boolean logTfs = getLogTfs(params); boolean includeExisting = getIncludeExisting(params); final SolrIndexSearcher searcher = rb.req.getSearcher(); IndexReader ir = searcher.getIndexReader(); Analyzer analyzer = searcher.getSchema().getIndexAnalyzer(); DocListAndSet docs = rb.getResults(); DocIterator iterator = docs.docList.iterator(); String uniqueKeyField = searcher.getSchema().getUniqueKeyField().getName(); NamedList<NamedList<Double>> topPredictions = new NamedList<NamedList<Double>>(); while(iterator.hasNext()) { int docNum = iterator.nextDoc(); Map<String, Map<String,Integer>> tf = getFieldTermFrequencyCounts(fields, ir, analyzer, docNum); NamedList<Double> predictions = predict(tf, topN, binary, logTfs, includeExisting); String uniqueFieldValue = getUniqueKeyFieldValue(ir, analyzer, uniqueKeyField, docNum); topPredictions.add(String.format("%s:%s", uniqueKeyField, uniqueFieldValue), predictions); } long duration = System.currentTimeMillis() - startTime; NamedList<Object> results = new NamedList<Object>(); results.add("Time", duration); results.add("values", topPredictions); rb.rsp.add(getPrefix(), results); } }
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)); }
Map<SolrDocument, Integer> ids ) throws IOException IndexSchema schema = searcher.getSchema();
Map<SolrDocument, Integer> ids ) throws IOException DocumentBuilder db = new DocumentBuilder(searcher.getSchema()); SolrDocumentList list = new SolrDocumentList(); list.setNumFound(docs.matches());
moreLikeThis.setPayloadFields(payloadFields); moreLikeThis.setAnalyzer(searcher.getSchema().getIndexAnalyzer());
facets = new String[0]; // make sure it is something... SchemaField sf = searcher.getSchema().getField(f); FieldType ft = sf.getType(); NamedList stv;