SOLR中的实体查询问题

时间:2017-08-03 10:38:15

标签: mysql solr

我正在尝试在data-config.xml中运行以下查询并尝试导入产品。但我收到以下错误

  

org.apache.solr.handler.dataimport.DataImportHandlerException:无法>执行查询:SELECT oh.tax_class_id as tax_class_id FROM oc_hsn oh> WHERE oh.hsn_code = Processing Document#1

我的查询如下:

 <entity name="hsn_data"
   query="SELECT oh.tax_class_id as tax_class_id  
   FROM oc_hsn oh
         WHERE oh.hsn_code=${products.hsn_code}" 
 />

这里的products.hsn_code是hsn_Code,它是VARCHAR(8)类型。

这不是该表的主键。

我不知道如何使用此hsn_Code来处理此查询。

是否只能在实体中的WHERE子句后使用主键? 请点亮一下

我的数据配置如下:

 <entity name="products" transformer="RegexTransformer"
  query="SELECT 
  p.product_id as id,
  p.hsn_code as hsn_code, 
  GROUP_CONCAT(DISTINCT(pc.category_id) separator ',') as    category_id,
  GROUP_CONCAT(DISTINCT(cd.name) separator ',') as categories,
  GROUP_CONCAT(DISTINCT(pf.filter_id) separator ',') as filter_id,
  GROUP_CONCAT(DISTINCT(fd.name) separator ',') as filters,
  GROUP_CONCAT(DISTINCT(p2s.store_id) separator ',') as store_id
  FROM oc_product AS p
  LEFT JOIN oc_product_description AS pd ON p.product_id = pd.product_id
  LEFT JOIN oc_stock_status AS ss ON ss.stock_status_id = p.stock_status_id
  LEFT JOIN oc_product_to_category AS pc ON pc.product_id = p.product_id
  LEFT JOIN oc_category_description AS cd ON cd.category_id = pc.category_id 
 LEFT JOIN oc_product_filter AS pf ON pf.product_id = p.product_id
 LEFT JOIN oc_filter_description AS fd ON fd.filter_id = pf.filter_id 
 LEFT JOIN oc_product_to_store AS p2s ON p2s.product_id = p.product_id
 GROUP BY p.product_id" 

 deltaImportQuery="SELECT 
  p.product_id as id,
  p.hsn_code as hsn_code, 
  GROUP_CONCAT(DISTINCT(pc.category_id) separator ',') as category_id,
  GROUP_CONCAT(DISTINCT(cd.name) separator ',') as categories,
  GROUP_CONCAT(DISTINCT(pf.filter_id) separator ',') as filter_id,
  GROUP_CONCAT(DISTINCT(fd.name) separator ',') as filters,
  GROUP_CONCAT(DISTINCT(p2s.store_id) separator ',') as store_id
  FROM oc_product AS p
  LEFT JOIN oc_product_description AS pd ON p.product_id = pd.product_id
  LEFT JOIN oc_stock_status AS ss ON ss.stock_status_id = p.stock_status_id
  LEFT JOIN oc_product_to_category AS pc ON pc.product_id = p.product_id
  LEFT JOIN oc_category_description AS cd ON cd.category_id = pc.category_id 
 LEFT JOIN oc_product_filter AS pf ON pf.product_id = p.product_id
 LEFT JOIN oc_filter_description AS fd ON fd.filter_id = pf.filter_id 
 LEFT JOIN oc_product_to_store AS p2s ON p2s.product_id = p.product_id   
 WHERE p.product_id='${products.id}'
 GROUP BY p.product_id"

 deltaQuery="
  SELECT p.product_id as id, p.date_modified , p.hsn_code as hsn_code
  FROM oc_product AS p
  WHERE p.date_modified > '${products.last_index_time}'" >

<entity name="hsn_data"
  query="SELECT oh.tax_class_id as tax_class_id  
         FROM oc_hsn oh
         WHERE oh.hsn_code=${products.hsn_code}" />

  <field column="id" sourceColName="id" />
  <field column="tax_class_id" sourceColName="tax_class_id"  />
  <field column="hsn_code" sourceColName="hsn_code"  />
  </entity>

先谢谢

0 个答案:

没有答案