Package org.apache.solr.schema

Examples of org.apache.solr.schema.IndexSchema$DynamicReplacement


    NamedList dbg = null;
    if (debug!=null) {
      dbg = new SimpleOrderedMap();

      SolrIndexSearcher searcher = req.getSearcher();
      IndexSchema schema = req.getSchema();

      boolean explainStruct
        = req.getParams().getBool(CommonParams.EXPLAIN_STRUCT,false);
     
      /* userQuery may have been pre-processes .. expose that */
 
View Full Code Here


    SolrParams params = req.getParams();
    if (!isHighlightingEnabled(params))
        return null;
    
    SolrIndexSearcher searcher = req.getSearcher();
    IndexSchema schema = searcher.getSchema();
    NamedList fragments = new SimpleOrderedMap();
    String[] fieldNames = getHighlightFields(query, req, defaultFields);
    Set<String> fset = new HashSet<String>();
    
    {
      // pre-fetch documents using the Searcher's doc cache
      for(String f : fieldNames) { fset.add(f); }
      // fetch unique key if one exists.
      SchemaField keyField = schema.getUniqueKeyField();
      if(null != keyField)
        fset.add(keyField.getName())
    }

    // get FastVectorHighlighter instance out of the processing loop
    FastVectorHighlighter fvh = new FastVectorHighlighter(
        // FVH cannot process hl.usePhraseHighlighter parameter per-field basis
        params.getBool( HighlightParams.USE_PHRASE_HIGHLIGHTER, true ),
        // FVH cannot process hl.requireFieldMatch parameter per-field basis
        params.getBool( HighlightParams.FIELD_MATCH, false ) );
    fvh.setPhraseLimit(params.getInt(HighlightParams.PHRASE_LIMIT, Integer.MAX_VALUE));
    FieldQuery fieldQuery = fvh.getFieldQuery( query, searcher.getIndexReader() );

    // Highlight each document
    DocIterator iterator = docs.iterator();
    for (int i = 0; i < docs.size(); i++) {
      int docId = iterator.nextDoc();
      Document doc = searcher.doc(docId, fset);
      NamedList docSummaries = new SimpleOrderedMap();
      for (String fieldName : fieldNames) {
        fieldName = fieldName.trim();
        if( useFastVectorHighlighter( params, schema, fieldName ) )
          doHighlightingByFastVectorHighlighter( fvh, fieldQuery, req, docSummaries, docId, doc, fieldName );
        else
          doHighlightingByHighlighter( query, req, docSummaries, docId, doc, fieldName );
      }
      String printId = schema.printableUniqueKey(doc);
      fragments.add(printId == null ? null : printId, docSummaries);
    }
    return fragments;
  }
View Full Code Here

    String[] docTexts = doc.getValues(fieldName);
    // according to Document javadoc, doc.getValues() never returns null. check empty instead of null
    if (docTexts.length == 0) return;
   
    SolrIndexSearcher searcher = req.getSearcher();
    IndexSchema schema = searcher.getSchema();
    TokenStream tstream = null;
    int numFragments = getMaxSnippets(fieldName, params);
    boolean mergeContiguousFragments = isMergeContiguousFragments(fieldName, params);

    String[] summaries = null;
View Full Code Here

   */
  private static SimpleOrderedMap<Object> getCoreInfo( SolrCore core ) throws Exception
  {
    SimpleOrderedMap<Object> info = new SimpleOrderedMap<Object>();
   
    IndexSchema schema = core.getSchema();
    info.add( "schema", schema != null ? schema.getSchemaName():"no schema!" );
   
    // Host
    InetAddress addr = InetAddress.getLocalHost();
    info.add( "host", addr.getCanonicalHostName() );

View Full Code Here

      }

      //there should only be one
      if (queryConverters.size() == 1) {
        queryConverter = queryConverters.values().iterator().next();
        IndexSchema schema = core.getSchema();
        String fieldTypeName = (String) initParams.get("queryAnalyzerFieldType");
        FieldType fieldType = schema.getFieldTypes().get(fieldTypeName);
        Analyzer analyzer = fieldType == null ? new WhitespaceAnalyzer(core.getSolrConfig().luceneMatchVersion)
                : fieldType.getQueryAnalyzer();
        //TODO: There's got to be a better way!  Where's Spring when you need it?
        queryConverter.setAnalyzer(analyzer);
      }
View Full Code Here

    }

    @Deprecated
    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;
    }
View Full Code Here

      if (sconfig.getBool("abortOnConfigurationError",defaultAbortOnConfigError)) {
        numCoresAbortOnConfigError++;
      }
     
      IndexSchema ischema = new IndexSchema(sconfig, p.getSchemaName(), null);
      SolrCore core = new SolrCore(p.getName(), p.getDataDir(), sconfig, ischema, p);
      core.setName(name);
      core.getCoreDescriptor().name = name;
     
      SolrCore old = cores.put(name, core);
View Full Code Here

  }
 
  public static void main(String[] args) throws IOException, ParserConfigurationException, SAXException, ClassNotFoundException {
   
    IndexSchema schema=null;
    SolrConfig solrConfig = new SolrConfig("E:\\一淘svn\\higo\\trunk\\adhoc-core\\solr\\conf\\solrconfig.xml");
      InputSource is = new InputSource(solrConfig.getResourceLoader().openSchema("E:\\一淘svn\\higo\\trunk\\adhoc-core\\solr\\conf\\schema.xml"));
      schema =new IndexSchema(solrConfig, "solrconfig",is);
    String s = "Ab94aa4CdDbd34dfde082ed1b4c4d0c505b69";

    StringReader sr = new StringReader(s);
//    Analyzer analyzer =new StandardAnalyzer((Version) Enum.valueOf((Class) Class.forName("org.apache.lucene.util.Version"),  Version.LUCENE_35.name()));
    Analyzer analyzer = schema.getAnalyzer();//JobIndexPublic.setAnalyzer(conf);
    TokenStream tk=analyzer.tokenStream("rawquery", sr);

    boolean hasnext = tk.incrementToken();

    while(hasnext){
View Full Code Here

    assertNull(tmp.getQueryAnalyzer());
  }

  @Test
  public void testSirenFieldDatatypeAnalyzer() throws Exception {
    final IndexSchema schema = h.getCore().getSchema();
    final SchemaField ntriple = schema.getField(JSON_FIELD);
    final FieldType tmp = ntriple.getType();

    TokenizerChain ts = (TokenizerChain) tmp.getAnalyzer();

    assertTrue(ts.getTokenFilterFactories()[0] instanceof DatatypeAnalyzerFilterFactory);
View Full Code Here

    initCore("solrconfig.xml", "schema-sirenfield.xml", SOLR_HOME);
  }

  @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);
  }
View Full Code Here

TOP

Related Classes of org.apache.solr.schema.IndexSchema$DynamicReplacement

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.