Interfaces to xapian

1,168 views
1,077 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,168
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
10
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Interfaces to xapian

  1. 1. Interfaces to Xapian Open source search day 2009
  2. 2. C++ #include <xapian.h> Xapian::WritableDatabase db(path, Xapian::DB_OPEN); Xapian::Document doc; doc.add_term(“foo”); db.add_document(doc);
  3. 3. Python: xapian import xapian db = xapian.WritableDatabase(path, xapian.DB_OPEN) doc = xapian.Document() doc.add_term(“foo”) db.add_document(doc)
  4. 4. Python: xappy from xappy import IndexerConnection, FieldActions db = xappy.IndexerConnection(path) db.add_field_action(“text”, FieldActions.INDEX_FREETEXT) doc = xappy.UnprocessedDocument() doc.append(“text”, “foo”) db.add(doc)
  5. 5. Python: xappy from xappy import IndexerConnection, FieldActions db = xappy.IndexerConnection(path) db.add_field_action(“text”, FieldActions.INDEX_FREETEXT, language=”french”) doc = xappy.UnprocessedDocument() doc.append(“text”, “foo”) db.add(doc)
  6. 6. from xappy2.core import * db = xappy.IndexerConnection(path) db.add_field_type(“text”, TEXT, language=”french”) db.add_index(“text”, StandardAnalyser) doc = xappy.UnprocessedDocument() doc.append(“text”, “foo”) db.add(doc) Python: xappy2.core
  7. 7. Python: xappy2.server REST based API
  8. 8. Python: xappy2.server PUT to /v1/dbs/dbname POST to /v1/dbs/dbname/schema/fields/text { 'type': 'text', 'freetext': {'language': 'en'} } } POST to /v1/dbs/dbname/docs { 'text': ['foo'] } (or PUT to /v1/dbs/dbname/docs/docid)
  9. 9. Python: Zope: ore.xapian Zope style layer on top of xappy: class Content( object ): ... implements( interfaces.IIndexable ) Asynchronous loading/updating, event integration, etc
  10. 10. Python: Django: Djapian Django integration layer on top of xapian import djapian class EntryIndexer(djapian.Indexer): fields=["text"] Tags=[ ("content", "content.text" ) ]
  11. 11. Python: Django: Haystack Another Django integration layer on top of xapian from haystack import indexes class TextIndex(indexes.SearchIndex): text = indexes.CharField(document=True, use_template=True)
  12. 12. Other Similar stack of interfaces for Ruby, PHP Java, C# just have bindings, so far
  13. 13. Image Searching with Xappy db.add_field_action('image', FieldActions.IMGSEEK, terms = True) doc.fields.append('image', path_to_image_file) db.add(doc) query = sconn.query_image_similarity('image', docid='0')

×