- 取得連結
- X
- 以電子郵件傳送
- 其他應用程式
an article has many tags,
query using solr, each article has many tag's id in one tag_id column
core_name/conf/db-data-config.xml
core_name/conf/schema.xml
query using solr, each article has many tag's id in one tag_id column
core_name/conf/db-data-config.xml
<?xml version="1.0" encoding="UTF-8" ?>
<dataConfig>
<dataSource name="db_source" type="JdbcDataSource"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://192.168.1.1/db"
user="xxx"
password="xxx"
/>
<document>
<entity name="article"
query="
SELECT id,title,content,
DATE_FORMAT(
a.updated_at,
'%Y-%m-%dT%H:%i:%s.001Z'
) AS updated_time
FROM articles
"
deltaImportQuery="
SELECT id,title,content,
DATE_FORMAT(
a.updated_at,
'%Y-%m-%dT%H:%i:%s.001Z'
) AS updated_time
FROM articles
WHERE id= '${dataimporter.delta.id}'
"
deltaQuery="
SELECT id,title,content,
DATE_FORMAT(
a.updated_at,
'%Y-%m-%dT%H:%i:%s.001Z'
) AS updated_time
FROM articles
WHERE updated_at > '${dataimporter.last_index_time}'
"
transformer="HTMLStripTransformer,RegexTransformer,TemplateTransformer"
dataSource="db_source"
>
<field column="updated_at" name="last_modified" />
<entity name="tag"
query="
SELECT id AS tag_id
FROM tags WHERE article_id = '${article.id}'
"
deltaImportQuery="
SELECT id AS tag_id
FROM tags
WHERE id = '${dataimporter.delta.id}'
"
deltaQuery="
SELECT id AS tag_id
FROM tags
WHERE updated_at > '${dataimporter.last_index_time}'
"
transformer="HTMLStripTransformer,RegexTransformer,TemplateTransformer"
dataSource="db_source"
>
<field column="updated_at" name="last_modified" />
</entity>
</entity>
</document>
</dataConfig>
core_name/conf/schema.xml
<?xml version="1.0" encoding="UTF-8" ?>
<schema name="demo" version="1.5">
<field name="id" type="int" indexed="true" stored="true" required="true" multiValued="false" />
<field name="title" type="string" indexed="true" stored="true" required="false" multiValued="false" />
<field name="content" type="htmlStripChinese" indexed="true" stored="true" required="false" multiValued="false" />
<field name="tag_id" type="int" indexed="true" stored="true" required="false" multiValued="true" />
<field name="updated_time" type="tdate" indexed="true" stored="true" required="false" multiValued="false" />
<field name="text_all" type="htmlStripChinese" indexed="true" stored="false" omitNorms="false" multiValued="true" />
<uniqueKey>id</uniqueKey>
<defaultSearchField>text_all</defaultSearchField>
<copyField source="title" dest="text_all"/>
<copyField source="content" dest="text_all"/>
</schema>
留言