如何设置中缀和sphinx搜索中的前缀索引

时间:2017-08-29 05:36:48

标签: ruby-on-rails-3 sphinx thinking-sphinx

我希望为几个字段添加中缀索引,并为表中的其他字段添加前缀索引。有没有办法在狮身人面像中做到这一点?

我正在使用infix_fields & prefix_fields

在Sphinx中寻找选项dict=keywords

2 个答案:

答案 0 :(得分:0)

为此,您可以在索引定义中为每个字段设置它:

 public void showDialog2 {
        final TutorialDialog messageDialog = TutorialDialog.newInstance();
      messageDialog.setTitle("How cool! You just copied a pro trader!")
          .setDescription("Let's proceed.")
          .setNegativeButtonText("Skip tutorial")
          .setPositiveButtonText("Let's proceed")
          .setOnNegativeButtonClickListener(new TutorialDialog.OnNegativeButtonClickListener() {
            @Override public void onNegativeButtonClick() {
              messageDialog.dismiss();
            }
          })
          .setOnPositiveButtonClickListener(new TutorialDialog.OnPositiveButtonClickListener() {
            @Override public void onPositiveButtonClick() {
              // TODO: 8/29/17 call next dialog
              messageDialog.dismiss();
              onContinueButtonClick();
            }
          });

        messageDialog.show(getActivity().getSupportFragmentManager(), "confirmation_tutorial_dialog");

    }

dict设置只能按索引设置,所以如果你想要它用于特定的索引,可以将它添加到那些索引定义中:

indexes name, :infixes => true
indexes location, :prefixes => true

或者对于所有索引,将其添加到set_property :dict => ‘keywords’ 文件中的每个环境:

config/thinking_sphinx.yml

虽然在某些时候,我认为关键字将是(如果它还没有)Sphinx的默认字典设置。

答案 1 :(得分:0)

  ThinkingSphinx::Index.define(:incident, DEFAULT_INDEX_OPTIONS.merge(name: "incident_#{i}"), &Searchable.beetilable_index('Incident', index_count: incident_index_count, index_id: i) {
    indexes name
    set_property :min_prefix_len => 3
  })

  #
  # infix index (only for the title, symptom columns)
  #
  ThinkingSphinx::Index.define(:incident, DEFAULT_INDEX_OPTIONS.merge(name: "incident_#{i + incident_index_count + 1}"), &Searchable.beetilable_infix_index('Incident', index_count: incident_index_count, index_id: i) {
    indexes location
    set_property :min_infix_len => 3
  })
end