private FieldType dynFieldType(String fieldName) { for (DynamicField df : dynamicFields) { if (df.matches(fieldName)) return df.prototype.getType(); } return null; };
private static void addField(Document doc, SchemaField field, Object val, float boost) { if (val instanceof IndexableField) { doc.add((IndexableField) val); } else { for (IndexableField f : field.getType().createFields(field, val, boost)) { if (f != null) doc.add((Field) f); // null fields are not added } } }
public static FieldType getFieldType(String fieldName, IndexSchema indexSchema){ SchemaField field = indexSchema.getField(fieldName); return field.getType(); }
public ValueSource getValueSource(FunctionQParser fp, String arg) { if (arg==null) return null; SchemaField f = fp.req.getSchema().getField(arg); if (f.getType().getClass() == DateField.class || f.getType().getClass() == LegacyDateField.class) { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Can't use ms() function on non-numeric legacy date field " + arg); } return f.getType().getValueSource(f, fp); }
@Override protected HashMap<String,Analyzer> analyzerCache() { HashMap<String,Analyzer> cache = new HashMap<String,Analyzer>(); for (SchemaField f : getFields().values()) { Analyzer analyzer = f.getType().getQueryAnalyzer(); cache.put(f.getName(), analyzer); } return cache; }
protected HashMap<String,Analyzer> analyzerCache() { HashMap<String,Analyzer> cache = new HashMap<String,Analyzer>(); for (SchemaField f : getFields().values()) { Analyzer analyzer = f.getType().getAnalyzer(); cache.put(f.getName(), analyzer); } return cache; }
public boolean isFieldPhraseQueryable(final SchemaField field) { if (field != null) { final FieldType fieldType = field.getType(); return (fieldType instanceof TextField) && !field.omitPositions() && !field.omitTermFreqAndPositions(); } return false; }
public FieldValueCountCollapseCollector(SolrIndexSearcher searcher, String collapseField) { super(searcher); IndexSchema schema = searcher.getSchema(); collapseFieldType = schema.getField(collapseField).getType(); }
protected Query getRangeQuery(String field, String part1, String part2, boolean inclusive) throws ParseException { checkNullField(field); SchemaField sf = schema.getField(field); return sf.getType().getRangeQuery(parser, sf, "*".equals(part1) ? null : part1, "*".equals(part2) ? null : part2, inclusive, inclusive); }
/** * Macro for getting the numDocs of range over docs * @see SolrIndexSearcher#numDocs * @see TermRangeQuery */ protected int rangeCount(SchemaField sf, String low, String high, boolean iLow, boolean iHigh) throws IOException { Query rangeQ = sf.getType().getRangeQuery(null, sf,low,high,iLow,iHigh); return searcher.numDocs(rangeQ ,base); }
protected int rangeCount(SchemaField sf, Date low, Date high, boolean iLow, boolean iHigh) throws IOException { Query rangeQ = ((DateField)(sf.getType())).getRangeQuery(null, sf,low,high,iLow,iHigh); return searcher.numDocs(rangeQ ,base); }
@Override public ValueSource getValueSource(SchemaField field, QParser parser) { return new DateFieldSource(field.getName(), field.getType()); }
/** Add the xpathFields to the indexConfig using information about the field drawn from the schema. */ private void addXPathFields() { for (Entry<String,String> f : xpathFieldConfig) { SchemaField field = schema.getField(f.getKey()); FieldType fieldType = field.getType(); if (fieldType == null) { throw new SolrException(ErrorCode.SERVER_ERROR, "Field " + f.getKey() + " declared in lux config, but not defined in schema"); } XPathField xpathField = new XPathField(f.getKey(), f.getValue(), fieldType.getAnalyzer(), field.stored() ? Store.YES : Store.NO, field); indexConfig.addField(xpathField); } }
@Override protected Query getFieldQuery(String field, String queryText, boolean quoted) throws SyntaxError { SchemaField sf = this.schema.getFieldOrNull(field); //TODO cache this check if (sf != null) { final String fieldTypeName = sf.getType().getTypeName().toLowerCase(); if(fieldTypeName.contains("payload") || fieldTypeName.contains("vector")) { return new PayloadScoreQuery(new SpanTermQuery(new Term(field, queryText)), new AveragePayloadFunction(), false); } } return super.getFieldQuery(field, queryText, quoted); } }
public UpdateHandler(SolrCore core) { this.core=core; schema = core.getSchema(); idField = schema.getUniqueKeyField(); idFieldType = idField!=null ? idField.getType() : null; idTerm = idField!=null ? new Term(idField.getName(),"") : null; parseEventListeners(); }
@Test public void testConciseSirenFieldType() throws Exception { final IndexSchema schema = h.getCore().getLatestSchema(); SchemaField json = schema.getField("concise"); assertNotNull(json); FieldType tmp = json.getType(); assertTrue(tmp instanceof ConciseJsonField); json = schema.getField("concise-attribute-wildcard"); assertNotNull(json); tmp = json.getType(); assertTrue(tmp instanceof ConciseJsonField); }
@Test public void testSirenFieldType() throws Exception { final IndexSchema schema = h.getCore().getSchema(); final SchemaField ntriple = schema.getField(JSON_FIELD); assertNotNull(ntriple); final FieldType tmp = ntriple.getType(); assertTrue(tmp instanceof SirenField); }
@Test public void testSirenFieldType() throws Exception { final IndexSchema schema = h.getCore().getLatestSchema(); final SchemaField ntriple = schema.getField(JSON_FIELD); assertNotNull(ntriple); final FieldType tmp = ntriple.getType(); assertTrue(tmp instanceof ExtendedJsonField); }
@Test public void testSirenFieldTypeProperties() throws Exception { final IndexSchema schema = h.getCore().getSchema(); final FieldType type = schema.getField("json").getType(); assertTrue(type instanceof SirenField); assertFalse(type.isMultiValued()); assertTrue(type.isTokenized()); assertEquals(type.getPostingsFormat(), Siren10AForPostingsFormat.NAME); }
@Test public void testSirenFieldTypeProperties() throws Exception { final IndexSchema schema = h.getCore().getLatestSchema(); final FieldType type = schema.getField("json").getType(); assertTrue(type instanceof ExtendedJsonField); assertFalse(type.isMultiValued()); assertTrue(type.isTokenized()); assertEquals(type.getPostingsFormat(), Siren10AForPostingsFormat.NAME); }