如何用学说进行全文搜索?

时间:2010-02-11 08:42:42

标签: php database orm doctrine full-text-search

WHERE column = value    ->add(column, value);
WHERE column <> value   ->add(column, value, Criteria::NOT_EQUAL);
Other Comparison Operators  
> , <   Criteria::GREATER_THAN, Criteria::LESS_THAN
>=, <=  Criteria::GREATER_EQUAL, Criteria::LESS_EQUAL
IS NULL, IS NOT NULL    Criteria::ISNULL, Criteria::ISNOTNULL
LIKE, ILIKE     Criteria::LIKE, Criteria::ILIKE
IN, NOT IN  Criteria::IN, Criteria::NOT_IN
Other SQL Keywords  
ORDER BY column ASC     ->addAscendingOrderByColumn(column);
ORDER BY column DESC    ->addDescendingOrderByColumn(column);
LIMIT limit     ->setLimit(limit)
OFFSET offset   ->setOffset(offset)
FROM table1, table2 WHERE table1.col1 = table2.col2     ->addJoin(col1, col2)
FROM table1 LEFT JOIN table2 ON table1.col1 = table2.col2   ->addJoin(col1, col2, Criteria::LEFT_JOIN)
FROM table1 RIGHT JOIN table2 ON table1.col1 = table2.col2  ->addJoin(col1, col2, Criteria::RIGHT_JOIN)

以上都是基本操作,全文搜索的等价物是什么?

1 个答案:

答案 0 :(得分:3)

关于Searching的Doctrine文档很好地描述了这一点。

总结:

  • 您必须将行为Searchable添加到模型定义中,并配置应编入索引的字段。
  • 您可能需要设置文档中说明的其他内容。
  • 您可以使用search进行搜索,例如:

    $newsItemTable = Doctrine_Core::getTable('NewsItem');
    $results = $newsItemTable->search('test');