GithubHelp home page GithubHelp logo

Comments (3)

askdkc avatar askdkc commented on September 26, 2024 1

This is probably too late to answer your question but you can use pgroonga_query_expand function to achieve that.

Here is an example:

CREATE EXTENSION pgroonga;

-- create synonyms table
CREATE TABLE synonym_groups (
  synonyms text[]
);

-- Add PGroonga Index
CREATE INDEX synonym_groups_synonyms
          ON synonym_groups
       USING pgroonga (synonyms pgroonga_text_array_term_search_ops_v2);

-- Insert synonyms words into table
INSERT INTO synonym_groups
  VALUES (ARRAY['أحمد', 'احمد']);

-- Create sample data to try synonyms search
CREATE TABLE sample_texts (
  sample text
);

-- Add PGroonga index
CREATE INDEX sample_texts_index     
          ON sample_texts   
       USING pgroonga (sample pgroonga_text_full_text_search_ops_v2);


-- I'm not familiar with Arabic Language so if something wrong with sample text down below, my apologies.
INSERT INTO sample_texts  
  VALUES ('أحمد عبدالواحد');
INSERT INTO sample_texts  
  VALUES (' لمعانٍ أخرى، طالع أحمد (توضيح).');


-- Now you can search either 'أحمد'OR  'احمد' and get both results back.
SELECT * FROM sample_texts 
     WHERE sample &@~ pgroonga_query_expand('synonym_groups', 'synonyms', 'synonyms', 'احمد');
--             sample              
---------------------------------
-- أحمد عبدالواحد
  -- لمعانٍ أخرى، طالع أحمد (توضيح).
-- (2 rows)


SELECT * FROM sample_texts 
     WHERE sample &@~ pgroonga_query_expand('synonym_groups', 'synonyms', 'synonyms', 'أحمد');
--             sample              
---------------------------------
-- أحمد عبدالواحد
  -- لمعانٍ أخرى، طالع أحمد (توضيح).
-- (2 rows)

Hope this will help you.

from pgroonga.github.io.

salmagomaa avatar salmagomaa commented on September 26, 2024

Thank you @askdkc , I will give it a try.

from pgroonga.github.io.

kou avatar kou commented on September 26, 2024

You can use NormalizerMySQLUnicode900 normalizer:

CREATE INDEX pgroonga_content_index
          ON memos
       USING pgroonga (content)
        WITH (plugins='normalizers/mysql',
              normalizers='NormalizerMySQLUnicode900');

Note that you need to install groonga-normalizer-mysql package for this.

See also:

from pgroonga.github.io.

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.