Hot questions for Using Cassandra in lucene

Question:

I am just experimenting with Lucene and want to indexing objects in Database(Cassandra) as a table. But, I didnt realized out, how the indexing does work on Cassandra. Especially searching...

When i take a simple Example

Indexing in Lucene:

Document doc = new Document();
doc.add(new TextField("id", "Hotel-1345", Field.Store.YES));
doc.add(new TextField("description", "A beautiful hotel", Field.Store.YES));
writer.addDocument(doc);

then Lucene will create index File (C:..) And Querying works well, with indexSearcher. But...

Indexing Database? I think i cant just create a simple table like that

Table1:  
ID        , Description
------------------
Hotel-1345, A beautiful hotel

How does the searching process of lucene works? How should the database structur be?

hope, i get some answers :/


Answer:

It will not look like a relational database table, instead Lucene uses the inverted index and cosine similarity formula for searching of any search words.

To better understand you need to look for various terminology and formula to be used in lucene, you can check out it on lucene officially website, https://lucene.apache.org/core/3_5_0/scoring.html#Query%20Classes

To index data you need to make use of the Lucene indexer and searcher API use this pseudo code for indexing :

    Directory directory = null;
    IndexWriter writer = null;
    try {
        directory = FSDirectory.open(new File(args[0]));
        IndexWriterConfig iwConf = new IndexWriterConfig(Version.LUCENE_48,
                new KeywordAnalyzer());
        iwConf.setOpenMode(IndexWriterConfig.OpenMode.CREATE);
        writer = new IndexWriter(directory, iwConf);
        Document document = new Document();
        document.add(new StringField("title", "Cat", Store.YES));
        writer.addDocument(document);
        writer.commit();
        writer.close();
    } catch (IOException e) {
        e.printStackTrace();
    }