Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support weight #6

Closed
kou opened this issue Feb 20, 2017 · 3 comments
Closed

Support weight #6

kou opened this issue Feb 20, 2017 · 3 comments

Comments

@kou
Copy link
Member

kou commented Feb 20, 2017

タイトル(issueならsubject)にキーワードが含まれていた場合は本文に含まれている場合よりも高いスコアーにして欲しい。理由はタイトルに含まれている方がより目的の項目である可能性が高いから。

@kou
Copy link
Member Author

kou commented Feb 20, 2017

カラム毎に重みを変えるには、まず、マルチカラムインデックスをやめる。マルチカラムインデクスではすべてのカラムを同じように扱ってしまうから。

マルチカラムインデックスをやめるには次のようにするとよさそう。

まず、新しくマイグレーションファイルを作る。

次に↑で↓みたいにする。

drop_index(:fts_projects, [:name, :identifier, :description])
add_index(:fts_projects, :name, type: "fulltext")
add_index(:fts_projects, :identifier, type: "fulltext")
add_index(:fts_projects, :description, type: "fulltext")
# ...

lib/full_text_search/mroonga.rbを次のように変える。

WHERE MATCH(name, identifier, description)

みたいなのを

WHERE MATCH(name) ... OR
      MATCH(identifier) ... OR
      MATCH(description)

みたいにする。

SELECT ..., MATCH(name) ... as score

みたいなのを

SELECT ..., MATCH(name) ... * 100 +
            MATCH(identifier) ... * 100 +
            MATCH(description) ...
            as score

みたいにする。

@okkez
Copy link
Contributor

okkez commented Feb 23, 2017

813f7a8 で大体できた。
カラムごとのスコアの調整は要検討。

@okkez
Copy link
Contributor

okkez commented Mar 20, 2017

カラムごとのスコアの調整は、具体的な提案があれば検討する。

@okkez okkez closed this as completed Mar 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants