Package org.apache.lucene.search

Examples of org.apache.lucene.search.Hits.doc()


     */
    public String getService(String feedID) throws IOException {
        Hits hits = storageFeedQuery(feedID);
        if (hits.length() <= 0)
            return null;
        Document doc = hits.doc(0);
        String feedType = doc.get(StorageFeedWrapper.FIELD_SERVICE_ID);
        return feedType;
    }

    private Hits storageFeedQuery(String feedId) throws IOException {
View Full Code Here


     */
    public String getAccountNameForFeedId(String feedId) throws IOException {
        Hits h = storageFeedQuery(feedId);
        if (h.length() == 0)
            return null;
        Document doc = h.doc(0);
        return doc.get(StorageFeedWrapper.FIELD_ACCOUNTREFERENCE);

    }

    protected long getEntryLastModified(final String entryId,
View Full Code Here

            return wrapper.getTimestamp();

        Hits h = storageQuery(entryId);
        if (h.length() > 0)
            try {
                return Long.parseLong(h.doc(0).get(
                        StorageEntryWrapper.FIELD_TIMESTAMP));
            } catch (Exception e) {
                LOG.warn("Can not parse timestamp from entry -- "
                        + h.doc(0).get(StorageEntryWrapper.FIELD_TIMESTAMP));
            }
View Full Code Here

            try {
                return Long.parseLong(h.doc(0).get(
                        StorageEntryWrapper.FIELD_TIMESTAMP));
            } catch (Exception e) {
                LOG.warn("Can not parse timestamp from entry -- "
                        + h.doc(0).get(StorageEntryWrapper.FIELD_TIMESTAMP));
            }
        else
            throw new StorageException("Entry not found");
        return 0;
View Full Code Here

        if (bufferedTime != null)
            return bufferedTime;
        Hits entryHits = storageFeedQuery(feedId, this.timeStampSort);
        if (entryHits.length() > 0) {
            try {
                return Long.parseLong(entryHits.doc(0).getField(
                        StorageEntryWrapper.FIELD_TIMESTAMP).stringValue());
            } catch (Exception e) {
                LOG.warn("Can not parse timestamp from entry -- "
                        + entryHits.doc(0).get(
                                StorageEntryWrapper.FIELD_TIMESTAMP));
View Full Code Here

            try {
                return Long.parseLong(entryHits.doc(0).getField(
                        StorageEntryWrapper.FIELD_TIMESTAMP).stringValue());
            } catch (Exception e) {
                LOG.warn("Can not parse timestamp from entry -- "
                        + entryHits.doc(0).get(
                                StorageEntryWrapper.FIELD_TIMESTAMP));
            }
        }
        return 0;
View Full Code Here

            return wrapper.getVersion() == version;

        Hits h = storageQuery(id);
        if (h.length() < 1)
            return false;
        Document doc = h.doc(0);
        String fieldValue = null;
        try {
            fieldValue = doc.getField(StorageEntryWrapper.FIELD_VERSION)
                    .stringValue();
            int storedVersion = Integer.parseInt(fieldValue);
View Full Code Here

        IndexSearcher searcher = new IndexSearcher(this.dir);
        Query q = new TermQuery(new Term(StorageAccountWrapper.FIELD_ACCOUNTNAME,
                username));
        Hits h = searcher.search(q);
        assertEquals("length == 1", 1, h.length());
        GDataAccount storedUser = StorageAccountWrapper.buildEntity(h.doc(0));
        assertTrue(storedUser.equals(user));
        searcher.close();
    }

    public void testDeleteUser() throws StorageException, IOException {
View Full Code Here

        IndexSearcher searcher = new IndexSearcher(this.dir);
        Query q = new TermQuery(new Term(StorageAccountWrapper.FIELD_ACCOUNTNAME,
                username));
        Hits h = searcher.search(q);
        assertEquals("length == 1", 1, h.length());
        GDataAccount storedUser = StorageAccountWrapper.buildEntity(h.doc(0));
        assertTrue(storedUser.equals(user));

        assertFalse(storedUser.getPassword().equals(password));
        searcher.close();
    }
View Full Code Here

    public void testCollectHits() throws IOException {
        Query q = new TermQuery(new Term(FIELDNAME, FIELDVALUE));
        Hits hits = this.searcher.get().search(q);
        assertEquals(amountDocuments, hits.length());
        List<String> returnValue = this.gdataSearcher.collectHits(hits, 1, 0);
        assertEquals(hits.doc(0).getField(IndexDocument.FIELD_ENTRY_ID)
                .stringValue(), returnValue.get(0));

        returnValue = this.gdataSearcher.collectHits(hits, 1, 1);
        assertEquals(hits.doc(0).getField(IndexDocument.FIELD_ENTRY_ID)
                .stringValue(), returnValue.get(0));
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.