English 中文(简体)
页: 1
原标题:Oracle: Multi-Column "Closest Match" Autocomplete Strategy

I m 安装一个自动化设备,使用户能够进入部分文本,然后与表内4个不同栏目相匹配。 这方面的一个基本实例是:

+------------+-----------+--------+-----------------+
| first_name | last_name | login  | email           |
+------------+-----------+--------+-----------------+
| John       | Smith     | jsmith | [email protected]  |
| Johnny     | Ringo     | ringo  | [email protected] |
| Bob        | Jones     | bjones | [email protected]   |
| Jane       | Doe       | doej   | [email protected] |
+------------+-----------+--------+-----------------+

当用户进入“工作”时,我想与本表的记录相匹配,在这四栏中至少有一栏与“工作%”模式相匹配。 举例来说,只有头两条符合first_name。 页: 1 如果查询为“js”,则只有第一个记录与其login <>/code>和email栏值相符。 因此。 我也希望恢复类似规定的结果,即第一个结果是“最接近”结果,从而降低结果(标准汽车行为)。

I ve currently been trying to solve this problem using UTL_MATCH, and code that produces the following query:

SELECT first_name,
  last_name,
  login,
  email,
      (  utl_match.jaro_winkler_similarity(first_name,  js )
       + utl_match.jaro_winkler_similarity(last_name,  js )
       + utl_match.jaro_winkler_similarity(login,  js )
       + utl_match.jaro_winkler_similarity(email,  js )) similarity
FROM users
WHERE LOWER(first_name) LIKE LOWER( js% )
OR LOWER(last_name) LIKE LOWER( js% )
OR LOWER(login) LIKE LOWER( js% )
OR LOWER(email) LIKE LOWER( js% )
ORDER BY similarity DESC

这些结果与我一样准确,我已经看到了在野里的汽车残割,我与我一样工作,但不知道他们如何在后台执行。

谁能向我指出正确的方向?

最佳回答

搜查总是徒劳的。 你们开始采取非常好的基本做法。 我通常做的是建立一个通过触发器装载的二级表。 触发器装上用户表格中的一个主要关键,第二栏是“研究”栏。 举例来说,每一行将产生4行。 确保你在上个案件中储存成果,这样,你就可以将一栏和甲骨文索引作为索引,因为你与你一样的同yn。 这需要额外的表格,但表格可以通过触发器保持。

    create table searcher
    (
    user_id  number, --FK back to users
    search_column  varchar2(50) -- or whatever size column is appropriate
    );

    select u.first_name, u.last_name, u.login. u.email,
utl_match.jaro_winkler_similarity(search_column,  js )
    from users u
    join
    searcher s
    on (u.user_id = s.user_id)
    where s.search_column like upper( js% )
    order by 5;
问题回答

暂无回答




相关问题
Export tables from SQL Server to be imported to Oracle 10g

I m trying to export some tables from SQL Server 2005 and then create those tables and populate them in Oracle. I have about 10 tables, varying from 4 columns up to 25. I m not using any constraints/...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

How to make a one to one left outer join?

I was wondering, is there a way to make a kind of one to one left outer join: I need a join that matches say table A with table B, for each record on table A it must search for its pair on table B, ...

Insert if not exists Oracle

I need to be able to run an Oracle query which goes to insert a number of rows, but it also checks to see if a primary key exists and if it does, then it skips that insert. Something like: INSERT ALL ...

How can I store NULLs in NOT NULL field?

I just came across NULL values in NOT-NULL fields in our test database. How could they get there? I know that NOT-NULL constraints can be altered with NOVALIDATE clause, but that would change table s ...

Type reference scope

I m studying databases and am currently working on a object-relational DB project and I ve encountered a small problem with the number of possible constraints in an object table. I m using "Database ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...