Package com.flaptor.indextank.index

Examples of com.flaptor.indextank.index.BoostedDocument


            int recovered = 0;
            for (Pair<String, BoostedDocument> pair : allDocuments) {
                logger.debug("Document found!");
                String docId = pair.first();
               
                BoostedDocument boostedDocument = pair.last();
                Map<Integer, Double> doubleBoosts = Maps.newHashMap();
                for (Entry<Integer, Float> entry : boostedDocument.getBoosts().entrySet()) {
                    doubleBoosts.put(entry.getKey(), Double.valueOf(entry.getValue()));
                }
                Map<String,String> categories = boostedDocument.getCategories();
                int userTimestamp;
                try {
                    userTimestamp = Integer.parseInt(boostedDocument.getDocument().getField("timestamp"));
                } catch (NumberFormatException e) {
                    logger.warn("Invalid timestamp " +  boostedDocument.getDocument().getField("timestamp") + " for document " + docId + " -- SKIPPING DOCUMENT");
                    continue;
                }
                recovered++;
                if (onlyDynamicData) {
                    // this is only usefull for reddit, and only because it has an old version that doesn't recover variables from simpledb.
                    //System.out.println("Updating  docid:" + docId);
                    client.updateBoost(docId, doubleBoosts);
                    client.updateTimestampBoost(docId, userTimestamp);
                    client.updateCategories(docId, categories);
                } else {
                    //System.out.println("Adding  docid:" + docId);
                    if (boostedDocument.getDocument().asMap().size() > 0) {
                        Document doc = new Document();
                        doc.set_fields(boostedDocument.getDocument().asMap());
                        client.addDoc(docId, doc, userTimestamp, doubleBoosts);
                    } else {
                        client.updateBoost(docId, doubleBoosts);
                    }
                    client.updateCategories(docId, categories);
View Full Code Here


            IndexStorage storage = getStorage();
            BufferedReader in = new BufferedReader(new InputStreamReader(System.in), 200);
            String docId;
            System.out.println("Enter the document Ids to recover, separated by enters.\nHit ctr-d to end.");
            while ((docId = in.readLine()) != null && docId.length() != 0) {
                BoostedDocument doc;
                try {
                    doc = storage.getDocument(docId, false);
                } catch (NullPointerException e) {
                    System.out.println("document " + docId + " is not in the storage.\nDELETING DOCUMENT.");
                    client.delDoc(docId);
                    continue;
                }
                Map<Integer, Double> doubleBoosts = Maps.newHashMap();
                for (Entry<Integer, Float> entry : doc.getBoosts().entrySet()) {
                    doubleBoosts.put(entry.getKey(), Double.valueOf(entry.getValue()));
                }
                Map<String,String> categories = doc.getCategories();

                client.updateBoost(docId, doubleBoosts);
                client.updateTimestampBoost(docId, Integer.parseInt(doc.getDocument().getField("timestamp")));
                client.updateCategories(docId, categories);
                System.out.println("Updated boosts for document " + docId + ", boosts: " + doubleBoosts);
            }
        } catch (Exception ex) {
            throw new RuntimeException("Something BAD happened: ",ex);
View Full Code Here

TOP

Related Classes of com.flaptor.indextank.index.BoostedDocument

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.