Package org.apache.solr.schema

Examples of org.apache.solr.schema.FieldType


      schema=this.schema;
    }else{
      schema=readerleft.getSchema();
    }
   
    FieldType ftleft=schema.getFieldType(fieldLeft);
   
    String prefixLeft=TrieField.getMainValuePrefix(ftleft);
    Term tiLeft=new Term(fieldLeft, prefixLeft==null?"":prefixLeft);
    TermEnum teLeft = null;
    TermDocs tdleft=null;
    if(this.leftreader!=null)
    {
      this.joinRevert=new int[this.leftreader.maxDoc()+1];
      tdleft=this.leftreader.termDocs();
      teLeft=this.leftreader.terms(tiLeft);
    }else{
      this.joinRevert=new int[readerleft.getReader().maxDoc()+1];
      teLeft=readerleft.getReader().terms(tiLeft);
      tdleft=readerleft.getReader().termDocs();
    }
   
    for(int i=0;i<this.joinRevert.length;i++)
    {
      this.joinRevert[i]=-1;
    }
   

   
    FieldType ftright =readerright.getSchema().getFieldType(fieldRigth);
    String prefixRight=TrieField.getMainValuePrefix(ftright);
    Term tiRight=new Term(fieldRigth, prefixRight==null?"":prefixRight);
   
    TermEnum teRight = readerright.getReader().terms(tiRight.createTerm(prefixRight==null?"":prefixRight));
    TermDocs tdRight=readerright.getReader().termDocs();
    this.join=new int[readerright.getReader().maxDoc()+1][];
    for(int i=0;i<this.join.length;i++)
    {
      this.join[i]=null;
    }
   
    int[] docs = new int[1000];
    int[] freqs = new int[1000];
   
   
    int debugline=0;
   
    HashMap<Integer,HashSet<Integer>> join_tmp=new HashMap<Integer,HashSet<Integer>>();
//    HashMap<Integer,Integer> joinRevert_tmp=new HashMap<Integer,Integer>();
    for (;;) {
      Term tleft= teLeft.term();
      Term tRight=teRight.term();
     
     
      if (tleft == null||tRight==null) {
        LOG.info("###termbreak###"+String.valueOf(tleft)+">>>>"+String.valueOf(tRight)+","+fieldLeft+","+fieldRigth);
        break;
      }
      if((!tleft.field().equals(fieldLeft))||(!tRight.field().equals(fieldRigth)))
      {
        LOG.info("###termbreak fieldchange###"+String.valueOf(tleft)+">>>>"+String.valueOf(tRight)+","+fieldLeft+","+fieldRigth);
        break;
      }
     
      String tvleft=ftleft.indexedToReadable(tleft.text());
      String tvRight=ftright.indexedToReadable(tRight.text());


      if(tvleft.equals(tvRight))
      {
        if(debugline++<10)
View Full Code Here


    if (uif == null) {
      synchronized (lock) {
        uif = (HigoJoinInterface) cache.get(fvkey);
        if (uif == null) {
         
          FieldType ftleft=schema.getFieldType(fieldLeft);
          FieldType ftright =readerright.getSchema().getFieldType(fieldRigth);
          if(ftleft.isMultiValued()||ftright.isMultiValued())
          {
            throw new IOException("multi value");
          }else{
            uif = new HigoJoinSingleValues(reader,partion,schema,readerright,fieldLeft, fieldRigth);
          }
View Full Code Here

  public void init(String field, IndexReader reader,IndexSchema schema) throws IOException
  {
    this.bits = new BitDocSet(new OpenBitSet(reader.maxDoc()));
    this.field = field;
   
    FieldType schemaft=schema.getFieldType(field);
    String prefix=TrieField.getMainValuePrefix(schemaft);
    SchemaField sf = schema.getField(field);
    this.ft = sf.getType();
    this.isMultiValued = this.ft.isMultiValued()
    this.fieldDataType = UnInvertedFieldUtils.getDataType(this.ft);
View Full Code Here

   *
   * @return List of NamedLists containing the relevant information taken from the tokens
   */
  private List<NamedList> convertTokensToNamedLists(final List<AttributeSource> tokenList, AnalysisContext context) {
    final List<NamedList> tokensNamedLists = new ArrayList<NamedList>();
    final FieldType fieldType = context.getFieldType();
    final AttributeSource[] tokens = tokenList.toArray(new AttributeSource[tokenList.size()]);
   
    // sort the tokens by absoulte position
    ArrayUtil.mergeSort(tokens, new Comparator<AttributeSource>() {
      public int compare(AttributeSource a, AttributeSource b) {
        return arrayCompare(
          a.getAttribute(TokenTrackingAttribute.class).getPositions(),
          b.getAttribute(TokenTrackingAttribute.class).getPositions()
        );
      }
     
      private int arrayCompare(int[] a, int[] b) {
        int p = 0;
        final int stop = Math.min(a.length, b.length);
        while(p < stop) {
          int diff = a[p] - b[p];
          if (diff != 0) return diff;
          p++;
        }
        // One is a prefix of the other, or, they are equal:
        return a.length - b.length;
      }
    });

    for (int i = 0; i < tokens.length; i++) {
      AttributeSource token = tokens[i];
      final NamedList<Object> tokenNamedList = new SimpleOrderedMap<Object>();
      final String rawText = token.addAttribute(CharTermAttribute.class).toString();

      String text = fieldType.indexedToReadable(rawText);
      tokenNamedList.add("text", text);
      if (!text.equals(rawText)) {
        tokenNamedList.add("raw_text", rawText);
      }

View Full Code Here

  /**
   * @return a string representing a SchemaField's flags. 
   */
  private static String getFieldFlags( SchemaField f )
  {
    FieldType t = (f==null) ? null : f.getType();
   
    // see: http://www.nabble.com/schema-field-properties-tf3437753.html#a9585549
    boolean lazy = false; // "lazy" is purely a property of reading fields
    boolean binary = false; // Currently not possible
   
    StringBuilder flags = new StringBuilder();
    flags.append( (f != null && f.indexed())             ? FieldFlag.INDEXED.getAbbreviation() : '-' );
    flags.append( (t != null && t.isTokenized())         ? FieldFlag.TOKENIZED.getAbbreviation() : '-' );
    flags.append( (f != null && f.stored())              ? FieldFlag.STORED.getAbbreviation() : '-' );
    flags.append( (f != null && f.multiValued())         ? FieldFlag.MULTI_VALUED.getAbbreviation() : '-' );
    flags.append( (f != null && f.storeTermVector() )    ? FieldFlag.TERM_VECTOR_STORED.getAbbreviation() : '-' );
    flags.append( (f != null && f.storeTermOffsets() )   ? FieldFlag.TERM_VECTOR_OFFSET.getAbbreviation() : '-' );
    flags.append( (f != null && f.storeTermPositions() ) ? FieldFlag.TERM_VECTOR_POSITION.getAbbreviation() : '-' );
View Full Code Here

    for( Object o : doc.getFields() ) {
      Fieldable fieldable = (Fieldable)o;
      SimpleOrderedMap<Object> f = new SimpleOrderedMap<Object>();
     
      SchemaField sfield = schema.getFieldOrNull( fieldable.name() );
      FieldType ftype = (sfield==null)?null:sfield.getType();

      f.add( "type", (ftype==null)?null:ftype.getTypeName() );
      f.add( "schema", getFieldFlags( sfield ) );
      f.add( "flags", getFieldFlags( fieldable ) );

      Term t = new Term(fieldable.name(), ftype!=null ? ftype.storedToIndexed(fieldable) : fieldable.stringValue());

      f.add( "value", (ftype==null)?null:ftype.toExternal( fieldable ) );

      // TODO: this really should be "stored"
      f.add( "internal", fieldable.stringValue() )// may be a binary number

      byte[] arr = fieldable.getBinaryValue();
View Full Code Here

      }
     
      SimpleOrderedMap<Object> f = new SimpleOrderedMap<Object>();
     
      SchemaField sfield = schema.getFieldOrNull( fieldName );
      FieldType ftype = (sfield==null)?null:sfield.getType();

      f.add( "type", (ftype==null)?null:ftype.getTypeName() );
      f.add( "schema", getFieldFlags( sfield ) );
      if (sfield != null && schema.isDynamicField(sfield.getName()) && schema.getDynamicPattern(sfield.getName()) != null) {
        f.add("dynamicBase", schema.getDynamicPattern(sfield.getName()));
      }
View Full Code Here

  }

  private static void populateFieldInfo(IndexSchema schema,
    Map<String, List<String>> typeusemap, SimpleOrderedMap<Object> fields,
    SchemaField uniqueField, SchemaField f) {
      FieldType ft = f.getType();
      SimpleOrderedMap<Object> field = new SimpleOrderedMap<Object>();
      field.add( "type", ft.getTypeName() );
      field.add( "flags", getFieldFlags(f) );
      if( f.isRequired() ) {
        field.add( "required", f.isRequired() );
      }
      if( f.getDefaultValue() != null ) {
        field.add( "default", f.getDefaultValue() );
      }
      if (f == uniqueField){
        field.add("uniqueKey", true);
      }
      if (ft.getAnalyzer().getPositionIncrementGap(f.getName()) != 0) {
        field.add("positionIncrementGap", ft.getAnalyzer().getPositionIncrementGap(f.getName()));
      }
      field.add("copyDests", schema.getCopyFields(f.getName()));
      field.add("copySources", schema.getCopySources(f.getName()));

     
      fields.add( f.getName(), field );
     
      List<String> v = typeusemap.get( ft.getTypeName() );
      if( v == null ) {
        v = new ArrayList<String>();
      }
      v.add( f.getName() );
      typeusemap.put( ft.getTypeName(), v );
  }
View Full Code Here

  private void loadExternalFileDictionary(SolrCore core) {
    try {

      // Get the field's analyzer
      if (fieldTypeName != null && core.getSchema().getFieldTypeNoEx(fieldTypeName) != null) {
        FieldType fieldType = core.getSchema().getFieldTypes().get(fieldTypeName);
        // Do index-time analysis using the given fieldType's analyzer
        RAMDirectory ramDir = new RAMDirectory();

        LogMergePolicy mp = new LogByteSizeMergePolicy();
        mp.setMergeFactor(300);

        IndexWriter writer = new IndexWriter(
            ramDir,
            new IndexWriterConfig(core.getSolrConfig().luceneMatchVersion, fieldType.getAnalyzer()).
                setMaxBufferedDocs(150).
                setMergePolicy(mp).
                setOpenMode(IndexWriterConfig.OpenMode.CREATE)
        );
View Full Code Here

    NamedList<NamedList> analysisResults = new SimpleOrderedMap<NamedList>();

    NamedList<NamedList> fieldTypeAnalysisResults = new SimpleOrderedMap<NamedList>();
    if (request.getFieldTypes() != null)  {
      for (String fieldTypeName : request.getFieldTypes()) {
        FieldType fieldType = schema.getFieldTypes().get(fieldTypeName);
        fieldTypeAnalysisResults.add(fieldTypeName, analyzeValues(request, fieldType, null));
      }
    }

    NamedList<NamedList> fieldNameAnalysisResults = new SimpleOrderedMap<NamedList>();
    if (request.getFieldNames() != null)  {
      for (String fieldName : request.getFieldNames()) {
        FieldType fieldType = schema.getFieldType(fieldName);
        fieldNameAnalysisResults.add(fieldName, analyzeValues(request, fieldType, fieldName));
      }
    }

    analysisResults.add("field_types", fieldTypeAnalysisResults);
View Full Code Here

TOP

Related Classes of org.apache.solr.schema.FieldType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.