Skip to content

Instantly share code, notes, and snippets.

@piglovesyou
Last active December 28, 2015 22:59
Show Gist options
  • Save piglovesyou/7575354 to your computer and use it in GitHub Desktop.
Save piglovesyou/7575354 to your computer and use it in GitHub Desktop.
This is a SQLite version of a data-config.xml for https://github.com/dnephin/TracAdvancedSearchPlugin. Be aware you need a SQLite driver "org.sqlite.JDBC", which you can download from https://bitbucket.org/xerial/sqlite-jdbc and put sqlite-jdbc-X.X.X.jar in your ${SOLR_HOME}/contrib/dataimporthandler/lib/ or somewhere.
<!--
Data Import Configuration
This will load all your existing ticket and wiki data into the solr index.
If you use a database other then mysql you may need to change the queries
slightly. You will likely have to change the connection url as well.
To start this data import hit the following url (assumes solr is running
on the default port on localhost):
http://localhost:8983/solr/dataimport?command=full-import
For more details see:
http://wiki.apache.org/solr/DataImportHandler
-->
<dataConfig>
<dataSource
type="JdbcDataSource"
driver="org.sqlite.JDBC"
url="jdbc:sqlite:/path/to/your/sqlite.db"
batchSize="1000"
/>
<document>
<entity
name="wiki"
query="select
name,
version,
replace(datetime(round(time/1000000), 'unixepoch'), ' ', 'T')||'Z' AS time,
author,
text,
comment,
'wiki_'||name as id,
'wiki' as source
from wiki
order by time asc">
</entity>
<entity
name="ticket"
query="SELECT
'ticket_'||id AS id,
id AS ticket_id,
'ticket' AS source,
type,
replace(datetime(round(t.time/1000000), 'unixepoch'), ' ', 'T')||'Z' AS time,
replace(datetime(round(t.changetime/1000000), 'unixepoch'), ' ', 'T')||'Z' AS changetime,
component,
severity,
priority,
owner,
cc,
reporter AS author,
version AS ticket_version,
milestone,
status,
resolution,
summary AS name,
keywords,
description||group_concat(newvalue, ' ') as text
FROM ticket AS t LEFT JOIN ticket_change AS tc ON t.id=tc.ticket AND tc.field='comment'
GROUP BY t.id
">
</entity>
</document>
</dataConfig>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment