How do I add a new xappy database? (Also extending search flags)

3 views
Skip to first unread message

stuar...@gmail.com

unread,
Jan 9, 2009, 12:19:13 AM1/9/09
to xappy-discuss
Problem1.
I have about 500,000 reports stored in a sqlite database.
I search with a Xappy index.

Rather than back-up all 500,000 reports + new ones (about 40,000 year)
I want to just archive past records and only back-up the current
sqlite database and current xappy index.

I want to do my search on 2 databases (archive + current)
Thus I want to open the "current" database and add the "archvive"
database.
ie add_database() from within xappy

I have not been able to figure out how to add a new database.

(conn._index.add_database('current') did not work because
_index.add_database() did not like the parameter 'current')


Problem 2. Extending search flags - SOLVED

I wanted to extend the flags when I parse a query.



def _query_parse_with_fallback(self, qp, string, prefix=None):
"""Parse a query with various flags.

If the initial boolean pass fails, fall back to not using
boolean
operators.

"""

# I added this line in _query_parse_with_fallback()


self._qp_flags_sg = _xapian.QueryParser.FLAG_PURE_NOT |
_xapian.QueryParser.FLAG_WILDCARD

# End of addition


try:
q1 = self._query_parse_with_prefix(qp, string,
self._qp_flags_base |
self._qp_flags_phrase |
self._qp_flags_synonym
|
self._qp_flags_sg |
self._qp_flags_bool,
prefix)
except _xapian.QueryParserError, e:

Richard Boulton

unread,
Jan 9, 2009, 5:00:37 AM1/9/09
to xappy-...@googlegroups.com
On Thu, Jan 08, 2009 at 09:19:13PM -0800, stuar...@gmail.com wrote:
> I have not been able to figure out how to add a new database.
>
> (conn._index.add_database('current') did not work because
> _index.add_database() did not like the parameter 'current')

Probably the easiest way is to open a connection for the current database,
call it "currentconn", and do:

conn._index.add_database(currentconn._index)

However, note that this isn't an "officially supported" technique: in
particular, it will give the wrong results if the configuration of the
current database is not identical to the main database.

--
Richard

stuar...@gmail.com

unread,
Jan 10, 2009, 12:56:22 AM1/10/09
to xappy-discuss
That works - Thanks

On Jan 9, 9:00 pm, Richard Boulton <rich...@lemurconsulting.com>
wrote:
Reply all
Reply to author
Forward
0 new messages