r5 - 26 May 2004 - 23:48:24 - LeoGalambosYou are here: TWiki >  Egothor Web  >  EgothorFAQ > IndexingAPI

Problem

How can I index via API?

Solution

import org.egothor.dir.TankerImpl;
import org.egothor.parser.Tokenizer;
import org.egothor.data.*;
import org.egothor.parser.plain.Plain;
import org.egothor.parser.misc.*;

import java.io.StringReader;

public class Sample {
    public static void main(String[] args) throws Exception {
        TankerImpl index = new TankerImpl("index/",false,32,10);

        FTField field = new MyTxtField("This is my document");
        DocMetadata dm = new DocMetadata();
        dm.put("S","Some summary...");
        dm.put("L","Location of this doc is on my HDD...");
        dm.put("T","Title of the document...");
        Document doc = new Document(dm, field);

        index.append(doc);
        index.close();
    }
}

class MyTxtField extends FTField {
    String text;

    MyTxtField(String text) { this.text = text; }

    public Tokenizer words() {
        return
            new LowerCase( new Plain( new StringReader(text) ) );
    }
}

See: SearchingAPI

-- LeoGalambos - 15 Mar 2004

WebForm?
TopicClassification PublicFAQ
OperatingSystem

OsVersion

Edit | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r5 < r4 < r3 < r2 < r1 | More topic actions
Know.IndexingAPI moved from Know.Indexing on 16 Mar 2004 - 17:14 by LeoGalambos
 
Powered by TWiki
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback