Directory

← Back

LuceneContainer

The LuceneContainer is (lazy loading) Vaadin container integrated with the lucene index.

Author

Rating

Package includes LuceneContainer and LuceneFacade

Main features of the LuceneContainer

Container is indexed Fast server side Lazy loading Fast and versatile searches with field sorting Ability to create the index from cvs (or tab delimeted) file Ability to create the index from sql query You edit the index index on the fly You can export search results into database table

Main features of the LuceneFacade

Persistence integration based on the AppFoundation add-on
Ability to create index from the Pojos found from AppFoundation IFacade
Index is updated when the pojo is stored in the IFacade
DemoApplication that demonstrates a "real-world" usage of the LuceneFacade

Sample code

// ...
if (LuceneContainer.checkIndex(INDEXDIR)) {
   dataSource = new LuceneContainer(INDEXDIR);
   table.setContainerDataSource(dataSource);
   info = new Label("Index loaded, ready to make queries!");
}
//...
dataSource.search(query, LuceneContainer.DOC_IDENTIFIER, false);
table.setContainerDataSource(dataSource);
//...
        // ...
        luceneFacade = new LuceneFacade(LUCENE_VERSION, INDEX_DIR, UNIQUE_ID);

        // ...
        Button editButton = new Button("Edit");
        editButton.addListener(new Button.ClickListener() {
            private static final long serialVersionUID = -3593785583996681571L;

            public void buttonClick(ClickEvent event) {
                UPCEditor editor = new UPCEditor(EDITABLE_FIELDS);
                Object itemId = table.getValue();
                Item selectedItem = dataSource.getItem(itemId);
                String pojoId = selectedItem.getItemProperty(IDFIELD)
                        .getValue().toString();
                LuceneFacadeDemo app = LuceneFacadeDemo.getCurrent();
                UPCPojo pojo = (UPCPojo) app.getLuceneFacade().findPojo(
                        FacadeFactory.getFacade(), UPCPojo.class, pojoId);
                editor.setPojo(pojo);
                LuceneFacadeDemo.getCurrent().getMainWindow().addWindow(editor);
            }
        });

        // ...

        Button okButton = new Button("Ok");
        okButton.addListener(new Button.ClickListener() {
            private static final long serialVersionUID = -7931392904726598608L;

            public void buttonClick(ClickEvent event) {
                // commit changes
                upcForm.commit();
                LuceneFacadeDemo.getCurrent().getMainWindow().removeWindow(
                        UPCEditor.this);
                LuceneFacadeDemo.getCurrent().getLuceneFacade().storePojo(
                        FacadeFactory.getFacade(), pojo);
            }
        });

Compatibility

(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.

Version

Vaadin 7 (beta) version

Released
2012-04-18
Maturity
BETA
License
Apache License 2.0

Compatibility

Framework
Vaadin 7.0+
Vaadin 6.0+ in 1.0.2
Browser
Browser Independent
Online