Giter VIP home page Giter VIP logo

Comments (7)

okkez avatar okkez commented on May 29, 2024

PostgreSQLだとRedmine本体のクエリをそのまま使っているので本体の対応待ちになります。
MariaDB(MySQL)だと、自分でクエリ組み立てているので直せると思います。

from redmine_full_text_search.

y503unavailable avatar y503unavailable commented on May 29, 2024

自分の利用環境はMariaDBとMySQLです。
検討して頂けると有難いです。

該当処理は↓辺りでしょうか?自分には無理ですが。。
/lib/full_text_search/mroonga.rbの def self.after_save(record)

from redmine_full_text_search.

okkez avatar okkez commented on May 29, 2024

少し調べてみましたが、Redmine本体側の対応が必須でした。

カスタムフィールドを作るときに「検索対象」かどうか設定可能な種類は「テキスト」、「リスト」、「長いテキスト」の3つだけでした。「キーバリューリスト」は検索対象に指定することができません。
なので、まず「キーバリューリスト」を検索対象に指定できるようにする必要があります。
その後、acts_as_seachable の search_result_ranks_and_ids でクエリを書き換えればいいはずです。

from redmine_full_text_search.

okkez avatar okkez commented on May 29, 2024

LEFT OUTER JOIN が必要になるから where で or が簡単に書けない Rails4 だと辛い。

こんな感じのクエリが発行されれば結果は取れる。。。

SELECT DISTINCT
 pgroonga.score(issues) AS score,
 issues.updated_on AS order_target,
 "issues"."id"
 FROM "issues"
 INNER JOIN "projects"
   ON "projects"."id" = "issues"."project_id"
 INNER JOIN "custom_values"
   ON "custom_values"."customized_id" = "issues"."id" AND "custom_values"."customized_type" = 'Issue'
 LEFT JOIN "custom_field_enumerations"
   ON "custom_field_enumerations"."custom_field_id" = "custom_values"."custom_field_id" AND custom_field_enumerations.id::text = custom_values.value
 WHERE (projects.status <> 9
       AND projects.id IN (SELECT em.project_id FROM enabled_modules em WHERE em.name='issue_tracking'))
       AND ((custom_values.custom_field_id IN (2,3)
       AND (((1=1) AND (issues.tracker_id IN (SELECT tracker_id FROM custom_fields_trackers WHERE custom_field_id = custom_values.custom_field_id))
                   AND (EXISTS (SELECT 1 FROM custom_fields ifa WHERE ifa.is_for_all = 't' AND ifa.id = custom_values.custom_field_id)
                        OR issues.project_id IN (SELECT project_id FROM custom_fields_projects WHERE custom_field_id = custom_values.custom_field_id))))))
       AND (custom_values.value ILIKE '%作成中%' OR custom_field_enumerations.name ILIKE '%作成中%')
 ORDER BY score DESC, "issues"."id" DESC;

from redmine_full_text_search.

y503unavailable avatar y503unavailable commented on May 29, 2024

>なので、まず「キーバリューリスト」を検索対象に指定できるようにする必要があります。
>その後、acts_as_seachable の search_result_ranks_and_ids でクエリを書き換えればいいはずです。

お手数お掛けしてすみません。
現行のRedmineでは、キーバリューリストの文字列検索自体が未実装ということで了解です。

強引に行う場合、大きくは下記箇所の修正になるでしょうか。

fts_custom_valuesにキーバリューリスト内部の数値が入っているので、
リスト定義内容を後から変更された場合を無視すれば、対応可能かなと思っています。


1.カスタムフィールドの検索指定-キーバリューリストで指定可能にする。

1は検索したいCFについて↓を通過させる。
redmine_full_text_search/lib/full_text_search/mroonga.rb
searchable_custom_fields = ::CustomField.where(:type => "#{self.name}CustomField", :searchable => true).to_a

DB書換でcustom_fields searchable 0->1


2.issue保存時にfts_custom_values に書き込んでいる箇所、

  キーバリューリストの検索対象フィールドの場合に、IDではなく文字列を登録する。

class Callbacks
def self.after_save(record)
に変換処理を入れる。

from redmine_full_text_search.

okkez avatar okkez commented on May 29, 2024

その案だと Mroonga を使っている場合しか対応できませんし、将来 Redmine 本体で対応が入ったときのマイグレーションが困難になるので、やりたくないです。
このプラグインはなるべく本体からの乖離を少なくして Mroonga と Pgroonga に対応させる、という方針で開発しています。

from redmine_full_text_search.

y503unavailable avatar y503unavailable commented on May 29, 2024

設計方針了解しました。
自分の案は一部環境のみの対応で、好ましい対応方針では無いのは同意です。

Mroongaだけ対応でも役に立つ人は居るでしょうから、
自分でやってみて、動いたらForkして公開します。(時期未定、お勉強&github練習。。)

from redmine_full_text_search.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.