Examples of MapFieldSelector


Examples of org.apache.lucene.document.MapFieldSelector

        assertNull(document.get("year"));
    }

    @Test
    public void Load_SingleResult_FieldSelector() {
        Document document = query.where(title.ne("")).load(new MapFieldSelector("title")).singleResult();
        assertNotNull(document.get("title"));
        assertNull(document.get("year"));
    }
View Full Code Here

Examples of org.apache.lucene.document.MapFieldSelector

     * @return
     * @throws SearchException
     */
    public DBpediaResource getDBpediaResource(int docNo, String[] fieldsToLoad) throws SearchException {

        FieldSelector fieldSelector = new MapFieldSelector(fieldsToLoad);
        Document document = getDocument(docNo, fieldSelector);
        Field uriField = document.getField(LuceneManager.DBpediaResourceField.URI.toString());
        if (uriField==null)
            throw new SearchException("Cannot find URI for document "+document);

View Full Code Here

Examples of org.apache.lucene.document.MapFieldSelector

//        return resource;
//    }

    public SurfaceForm getSurfaceForm(int docNo) throws SearchException {
        String[] onlyUriAndTypes = {LuceneManager.DBpediaResourceField.SURFACE_FORM.toString()};
        FieldSelector fieldSelector = new MapFieldSelector(onlyUriAndTypes);
        Document document = getDocument(docNo,fieldSelector);
        Field sfField = document.getField(LuceneManager.DBpediaResourceField.SURFACE_FORM.toString());
        if (sfField==null)
            throw new SearchException("Cannot find SurfaceForm for document "+document);
View Full Code Here

Examples of org.apache.lucene.document.MapFieldSelector

        ScoreDoc[] hits = getHits(q);
        for (ScoreDoc d: hits) {
            int docNo = d.doc;
            String[] onlySf = {LuceneManager.DBpediaResourceField.SURFACE_FORM.toString()};
            //Surface Form field does not store frequency vector, but indexes surface forms multiple times.
            Document doc = getDocument(docNo, new MapFieldSelector(onlySf));
            String[] sfList = doc.getValues(LuceneManager.DBpediaResourceField.SURFACE_FORM.toString());

            //Need to filter sfList to keep only the elements that are equal to the sf (caution with lowercase)
            int i=0;
            for (String sfName: sfList) {
View Full Code Here

Examples of org.apache.lucene.document.MapFieldSelector

     * @param res
     * @return
     * @throws SearchException
     */
    public int getSupport(DBpediaResource res) throws SearchException {
        FieldSelector fieldSelector = new MapFieldSelector(uriAndCount);
        int support = 0;

        //if (res.support()>0) return res.support(); //TODO what happens if value is already set?

        List<Document> uris = getDocuments(res, fieldSelector);
View Full Code Here

Examples of org.apache.lucene.document.MapFieldSelector

      // so apply an additional optimization using LOAD_AND_BREAK instead:
      String key = fields.keySet().iterator().next();
      fields.put( key, FieldSelectorResult.LOAD_AND_BREAK );
    }
    if ( fields.size() != 0 ) {
      this.fieldSelector = new MapFieldSelector( fields );
    }
    // else: this.fieldSelector = null; //We need no fields at all
  }
View Full Code Here

Examples of org.apache.lucene.document.MapFieldSelector

   * @throws IOException
   */
  private String forceClassNameExtraction(int scoreDocIndex) throws IOException {
    Map<String, FieldSelectorResult> fields = new HashMap<String, FieldSelectorResult>( 1 );
    fields.put( DocumentBuilder.CLASS_FIELDNAME, FieldSelectorResult.LOAD_AND_BREAK );
    MapFieldSelector classOnly = new MapFieldSelector( fields );
    Document doc = queryHits.doc( scoreDocIndex, classOnly );
    return doc.get( DocumentBuilder.CLASS_FIELDNAME );
  }
View Full Code Here

Examples of org.apache.lucene.document.MapFieldSelector

    Directory dir2 = getDir2(random);
    ParallelReader pr = new ParallelReader();
    pr.add(IndexReader.open(dir1, false));
    pr.add(IndexReader.open(dir2, false));

    Document doc11 = pr.document(0, new MapFieldSelector("f1"));
    Document doc24 = pr.document(1, new MapFieldSelector(Arrays.<String>asList("f4")));
    Document doc223 = pr.document(1, new MapFieldSelector("f2", "f3"));
   
    assertEquals(1, doc11.getFields().size());
    assertEquals(1, doc24.getFields().size());
    assertEquals(2, doc223.getFields().size());
   
View Full Code Here

Examples of org.apache.lucene.document.MapFieldSelector

    if ( projectionSize != 0 ) {
      for ( String projectedField : projection ) {
        fields.put( projectedField, FieldSelectorResult.LOAD );
      }
    }
    this.fieldSelector = new MapFieldSelector( fields );
  }
View Full Code Here

Examples of org.apache.lucene.document.MapFieldSelector

      // so apply an additional optimization using LOAD_AND_BREAK instead:
      String key = fields.keySet().iterator().next();
      fields.put( key, FieldSelectorResult.LOAD_AND_BREAK );
    }
    if ( fields.size() != 0 ) {
      this.fieldSelector = new MapFieldSelector( fields );
    }
    // else: this.fieldSelector = null; //We need no fields at all
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.