2014-04-29 4 views
0

cakephp에서 solr 검색을 통합하려고합니다. 모든 것이 잘 작동하지만 mysql 쿼리에 GROUP_CONCATE를 추가하면 내 solr 검색을 인덱싱 할 수 없습니다. 내 코드는 아래에 나열된 코드 solr 검색 색인 검색에서 쉼표로 구분 된 값을 GROUP_CANCAT을 사용하여 생성했습니다.

<dataSource name="db2" type="JdbcDataSource" 
driver="com.mysql.jdbc.Driver" 
url="jdbc:mysql://localhost/website" 
user="webname" 
password="123456"/> 
<document name="content"> 
<entity name="web" 
transformer="RegexTransformer" 
query="SELECT (SELECT GROUP_CONCAT(name separator ',') FROM tags JOIN article_tags ON tags.id = article_tags.tag_id WHERE article_tags.article_id = article.id) as tagnames, 
Article.id, Article.title, Article.sub_title, Article.category_id, 
Article.section_title, Article.section_body, Category.id as cat_id, 
Category.name as cat_name, Recipe.id as recipe_id, Recipe.recipe_title, ArticleMultiBody.id as multi_id, 
ArticleMultiBody.body_title_1, ArticleMultiBody.body_text_1 FROM zahra.articles AS Article 
LEFT JOIN zahra.categories AS Category ON (Article.category_id = Category.id) 
LEFT JOIN zahra.recipes AS Recipe ON (Recipe.article_id = Article.id) 
LEFT JOIN zahra.article_multi_bodies AS ArticleMultiBody ON (ArticleMultiBody.article_id = Article.id) ORDER BY Article.title" 

deltaQuery="SELECT Article.id, Article.title, Article.sub_title, Article.category_id, Article.section_title, Article.section_body, Category.id as cat_id, Category.name as cat_name, Recipe.id as recipe_id, Recipe.recipe_title, ArticleMultiBody.id as multi_id, ArticleMultiBody.body_title_1, ArticleMultiBody.body_text_1 FROM zahra.articles AS Article LEFT JOIN zahra.categories AS Category ON (Article.category_id = Category.id) LEFT JOIN zahra.recipes AS Recipe ON (Recipe.article_id = Article.id) LEFT JOIN zahra.article_multi_bodies AS ArticleMultiBody ON (ArticleMultiBody.article_id = Article.id) ORDER BY Article.title"> 
    <field column="ID" name="id" /> 
    <field column="TITLE" name="title" /> 
    <field column="SUB_TITLE" name="sub_title" /> 
    <field column="SECTION_TITLE" name="section_title" /> 
    <field column="SECTION_BODY" name="section_body" /> 
    <field column="CATEGORY_ID" name="category_id" /> 
    <field column="CREATED" name="created" dateTimeFormat="Y-m-d h:i:s" /> 
    <field column="KEYWORDS" name="keywords" splitBy="," sourceColName="tagnames" /> 
</entity> 
</document> 

나는 문제가 아래에 나열됩니다.

(SELECT GROUP_CONCAT(name separator ',') FROM tags JOIN article_tags ON tags.id = article_tags.tag_id WHERE article_tags.article_id = article.id) as tagnames, 

나는 다음이 코드를 제거 내 SOLR 지수는 아주 잘 작동하지만이를 추가하면 인덱싱 SOLR 동안 얻을 오류 경우 "인덱싱에 실패했습니다. 다시 모든 변경 사항을 압 연."

"tagnames는"새로운 필드가있는 태그 같은 쉼표로 분리 된 값으로 구성 생성 예 : 식품, 건강, 피트니스 등

그래서 난 구분 값

답변

1

더블이 쉼표로 SOLR을 구성 할 "키워드"필드가 스키마에서 multiValued로 정의되어 있는지 확인하십시오. "Indexing Failed"는 일반적으로 그 이유를 알려주고 전체 스택 추적도 제공합니다.

다음 구현은 수행하려는 작업에 대해 더 잘 작동 할 수도 있습니다. 알림 "그룹 병합"쿼리를 완전히 제거하고이를 아래 엔티티로 추가했습니다. 조인과 필드 이름을 다시 확인하십시오. 이름 지정을 기반으로 연결 만 가정했습니다. 이렇게하면 추가 행렬을 수행하지 않습니다. 각 행마다 분할 작업

<dataSource name="db2" type="JdbcDataSource" 
      driver="com.mysql.jdbc.Driver" 
      url="jdbc:mysql://localhost/website" 
      user="webname" 
      password="123456"/> 
<document name="content"> 
<entity name="web" 
     transformer="RegexTransformer" 
     query="SELECT 
    Article.id, Article.title, Article.sub_title, Article.category_id, 
    Article.section_title, Article.section_body, Category.id as cat_id, 
    Category.name as cat_name, Recipe.id as recipe_id, Recipe.recipe_title, ArticleMultiBody.id as multi_id, 
    ArticleMultiBody.body_title_1, ArticleMultiBody.body_text_1 FROM zahra.articles AS Article 
    LEFT JOIN zahra.categories AS Category ON (Article.category_id = Category.id) 
    LEFT JOIN zahra.recipes AS Recipe ON (Recipe.article_id = Article.id) 
    LEFT JOIN zahra.article_multi_bodies AS ArticleMultiBody ON (ArticleMultiBody.article_id = Article.id) ORDER BY Article.title" 
     deltaQuery="SELECT article.id, article.title, article.sub_title, article.category_id, article.section_title, article.section_body, category.id AS cat_id, category.name AS cat_name, recipe.id AS recipe_id, recipe.recipe_title, articlemultibody.id AS multi_id, articlemultibody.body_title_1, articlemultibody.body_text_1 FROM zahra.articles AS Article LEFT JOIN zahra.categories AS CATEGORY ON (Article.category_id = CATEGORY.id) LEFT JOIN zahra.recipes AS Recipe ON (Recipe.article_id = Article.id) LEFT JOIN zahra.article_multi_bodies AS ArticleMultiBody ON (ArticleMultiBody.article_id = Article.id) ORDER BY Article.title"> 
    <field column="ID" name="id"/> 
    <field column="TITLE" name="title"/> 
    <field column="SUB_TITLE" name="sub_title"/> 
    <field column="SECTION_TITLE" name="section_title"/> 
    <field column="SECTION_BODY" name="section_body"/> 
    <field column="CATEGORY_ID" name="category_id"/> 
    <field column="CREATED" name="created" dateTimeFormat="Y-m-d h:i:s"/> 
    <field column="KEYWORDS" name="keywords" splitBy="," sourceColName="tagnames"/> 
    <entity name="keywords" 
      pk="ARTICLE_ID" 
      query="SELECT name FROM tags JOIN article_tags ON tags.id = article_tags.tag_id WHERE article_tags.article_id = '${web.ID}'"> 
    <field column="KEYWORDS" name="keywords"/> 
    </entity> 


</entity> 
</document>