How to use full text search in Persian using Postgresql?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







1















I'm using Postgresql 9.6 and I'd like to run a query like this:



select post_id 
from comments
where to_tsvector('pg_catalog.persian', comments.body) @@ to_tsquery('pg_catalog.persian', 'کتاب') ;


But Persian is not among the languages supported in postgresql dictionary:



postgres=# dF
List of text search configurations
Schema | Name | Description
------------+------------+---------------------------------------
pg_catalog | danish | configuration for danish language
pg_catalog | dutch | configuration for dutch language
pg_catalog | english | configuration for english language
pg_catalog | finnish | configuration for finnish language
pg_catalog | french | configuration for french language
pg_catalog | german | configuration for german language
pg_catalog | hungarian | configuration for hungarian language
pg_catalog | italian | configuration for italian language
pg_catalog | norwegian | configuration for norwegian language
pg_catalog | portuguese | configuration for portuguese language
pg_catalog | romanian | configuration for romanian language
pg_catalog | russian | configuration for russian language
pg_catalog | simple | simple configuration
pg_catalog | spanish | configuration for spanish language
pg_catalog | swedish | configuration for swedish language
pg_catalog | turkish | configuration for turkish language
(16 rows)


So I get error:




ERROR: text search configuration "pg_catalog.persian" does not exist




My default DB config is for English:



postgres=# show default_text_search_config;
default_text_search_config
----------------------------
pg_catalog.english
(1 row)


I've tried pg_catalog.simple but it returns anything, while there are results for کتاب.



So I'm wondering how can I make a Full text Search in this situation to get relevant Persian results?










share|improve this question




















  • 1





    Just a guess: Perhaps Postgres 10 could be of use to you, with its newly added support for the ICU library. See this article.

    – Basil Bourque
    May 7 '18 at 8:22













  • Thanks for the link but I'm pretty new to PG and compiling a bleeding edge and changing existing codebase is beyound my knowledge. I'd rather to see a guide to integrate a custom-made dictionary to my existing DB.

    – Karlom
    May 7 '18 at 8:37


















1















I'm using Postgresql 9.6 and I'd like to run a query like this:



select post_id 
from comments
where to_tsvector('pg_catalog.persian', comments.body) @@ to_tsquery('pg_catalog.persian', 'کتاب') ;


But Persian is not among the languages supported in postgresql dictionary:



postgres=# dF
List of text search configurations
Schema | Name | Description
------------+------------+---------------------------------------
pg_catalog | danish | configuration for danish language
pg_catalog | dutch | configuration for dutch language
pg_catalog | english | configuration for english language
pg_catalog | finnish | configuration for finnish language
pg_catalog | french | configuration for french language
pg_catalog | german | configuration for german language
pg_catalog | hungarian | configuration for hungarian language
pg_catalog | italian | configuration for italian language
pg_catalog | norwegian | configuration for norwegian language
pg_catalog | portuguese | configuration for portuguese language
pg_catalog | romanian | configuration for romanian language
pg_catalog | russian | configuration for russian language
pg_catalog | simple | simple configuration
pg_catalog | spanish | configuration for spanish language
pg_catalog | swedish | configuration for swedish language
pg_catalog | turkish | configuration for turkish language
(16 rows)


So I get error:




ERROR: text search configuration "pg_catalog.persian" does not exist




My default DB config is for English:



postgres=# show default_text_search_config;
default_text_search_config
----------------------------
pg_catalog.english
(1 row)


I've tried pg_catalog.simple but it returns anything, while there are results for کتاب.



So I'm wondering how can I make a Full text Search in this situation to get relevant Persian results?










share|improve this question




















  • 1





    Just a guess: Perhaps Postgres 10 could be of use to you, with its newly added support for the ICU library. See this article.

    – Basil Bourque
    May 7 '18 at 8:22













  • Thanks for the link but I'm pretty new to PG and compiling a bleeding edge and changing existing codebase is beyound my knowledge. I'd rather to see a guide to integrate a custom-made dictionary to my existing DB.

    – Karlom
    May 7 '18 at 8:37














1












1








1








I'm using Postgresql 9.6 and I'd like to run a query like this:



select post_id 
from comments
where to_tsvector('pg_catalog.persian', comments.body) @@ to_tsquery('pg_catalog.persian', 'کتاب') ;


But Persian is not among the languages supported in postgresql dictionary:



postgres=# dF
List of text search configurations
Schema | Name | Description
------------+------------+---------------------------------------
pg_catalog | danish | configuration for danish language
pg_catalog | dutch | configuration for dutch language
pg_catalog | english | configuration for english language
pg_catalog | finnish | configuration for finnish language
pg_catalog | french | configuration for french language
pg_catalog | german | configuration for german language
pg_catalog | hungarian | configuration for hungarian language
pg_catalog | italian | configuration for italian language
pg_catalog | norwegian | configuration for norwegian language
pg_catalog | portuguese | configuration for portuguese language
pg_catalog | romanian | configuration for romanian language
pg_catalog | russian | configuration for russian language
pg_catalog | simple | simple configuration
pg_catalog | spanish | configuration for spanish language
pg_catalog | swedish | configuration for swedish language
pg_catalog | turkish | configuration for turkish language
(16 rows)


So I get error:




ERROR: text search configuration "pg_catalog.persian" does not exist




My default DB config is for English:



postgres=# show default_text_search_config;
default_text_search_config
----------------------------
pg_catalog.english
(1 row)


I've tried pg_catalog.simple but it returns anything, while there are results for کتاب.



So I'm wondering how can I make a Full text Search in this situation to get relevant Persian results?










share|improve this question
















I'm using Postgresql 9.6 and I'd like to run a query like this:



select post_id 
from comments
where to_tsvector('pg_catalog.persian', comments.body) @@ to_tsquery('pg_catalog.persian', 'کتاب') ;


But Persian is not among the languages supported in postgresql dictionary:



postgres=# dF
List of text search configurations
Schema | Name | Description
------------+------------+---------------------------------------
pg_catalog | danish | configuration for danish language
pg_catalog | dutch | configuration for dutch language
pg_catalog | english | configuration for english language
pg_catalog | finnish | configuration for finnish language
pg_catalog | french | configuration for french language
pg_catalog | german | configuration for german language
pg_catalog | hungarian | configuration for hungarian language
pg_catalog | italian | configuration for italian language
pg_catalog | norwegian | configuration for norwegian language
pg_catalog | portuguese | configuration for portuguese language
pg_catalog | romanian | configuration for romanian language
pg_catalog | russian | configuration for russian language
pg_catalog | simple | simple configuration
pg_catalog | spanish | configuration for spanish language
pg_catalog | swedish | configuration for swedish language
pg_catalog | turkish | configuration for turkish language
(16 rows)


So I get error:




ERROR: text search configuration "pg_catalog.persian" does not exist




My default DB config is for English:



postgres=# show default_text_search_config;
default_text_search_config
----------------------------
pg_catalog.english
(1 row)


I've tried pg_catalog.simple but it returns anything, while there are results for کتاب.



So I'm wondering how can I make a Full text Search in this situation to get relevant Persian results?







postgresql full-text-search






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 7 '18 at 6:34









a_horse_with_no_name

41.4k779116




41.4k779116










asked May 7 '18 at 4:57









KarlomKarlom

1062




1062








  • 1





    Just a guess: Perhaps Postgres 10 could be of use to you, with its newly added support for the ICU library. See this article.

    – Basil Bourque
    May 7 '18 at 8:22













  • Thanks for the link but I'm pretty new to PG and compiling a bleeding edge and changing existing codebase is beyound my knowledge. I'd rather to see a guide to integrate a custom-made dictionary to my existing DB.

    – Karlom
    May 7 '18 at 8:37














  • 1





    Just a guess: Perhaps Postgres 10 could be of use to you, with its newly added support for the ICU library. See this article.

    – Basil Bourque
    May 7 '18 at 8:22













  • Thanks for the link but I'm pretty new to PG and compiling a bleeding edge and changing existing codebase is beyound my knowledge. I'd rather to see a guide to integrate a custom-made dictionary to my existing DB.

    – Karlom
    May 7 '18 at 8:37








1




1





Just a guess: Perhaps Postgres 10 could be of use to you, with its newly added support for the ICU library. See this article.

– Basil Bourque
May 7 '18 at 8:22







Just a guess: Perhaps Postgres 10 could be of use to you, with its newly added support for the ICU library. See this article.

– Basil Bourque
May 7 '18 at 8:22















Thanks for the link but I'm pretty new to PG and compiling a bleeding edge and changing existing codebase is beyound my knowledge. I'd rather to see a guide to integrate a custom-made dictionary to my existing DB.

– Karlom
May 7 '18 at 8:37





Thanks for the link but I'm pretty new to PG and compiling a bleeding edge and changing existing codebase is beyound my knowledge. I'd rather to see a guide to integrate a custom-made dictionary to my existing DB.

– Karlom
May 7 '18 at 8:37










1 Answer
1






active

oldest

votes


















0














use this.



select post_id 
from comments
where to_tsvector('simple', comments.body) @@ to_tsquery('simple', 'کتاب') ;


OR



select post_id 
from comments
where to_tsvector('simple', comments.body) @@ to_tsquery('کتاب') ;


Or use this extension:



https://pgroonga.github.io/tutorial/






share|improve this answer








New contributor




Ali Bagheri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "182"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f206002%2fhow-to-use-full-text-search-in-persian-using-postgresql%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    use this.



    select post_id 
    from comments
    where to_tsvector('simple', comments.body) @@ to_tsquery('simple', 'کتاب') ;


    OR



    select post_id 
    from comments
    where to_tsvector('simple', comments.body) @@ to_tsquery('کتاب') ;


    Or use this extension:



    https://pgroonga.github.io/tutorial/






    share|improve this answer








    New contributor




    Ali Bagheri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.

























      0














      use this.



      select post_id 
      from comments
      where to_tsvector('simple', comments.body) @@ to_tsquery('simple', 'کتاب') ;


      OR



      select post_id 
      from comments
      where to_tsvector('simple', comments.body) @@ to_tsquery('کتاب') ;


      Or use this extension:



      https://pgroonga.github.io/tutorial/






      share|improve this answer








      New contributor




      Ali Bagheri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.























        0












        0








        0







        use this.



        select post_id 
        from comments
        where to_tsvector('simple', comments.body) @@ to_tsquery('simple', 'کتاب') ;


        OR



        select post_id 
        from comments
        where to_tsvector('simple', comments.body) @@ to_tsquery('کتاب') ;


        Or use this extension:



        https://pgroonga.github.io/tutorial/






        share|improve this answer








        New contributor




        Ali Bagheri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.










        use this.



        select post_id 
        from comments
        where to_tsvector('simple', comments.body) @@ to_tsquery('simple', 'کتاب') ;


        OR



        select post_id 
        from comments
        where to_tsvector('simple', comments.body) @@ to_tsquery('کتاب') ;


        Or use this extension:



        https://pgroonga.github.io/tutorial/







        share|improve this answer








        New contributor




        Ali Bagheri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        share|improve this answer



        share|improve this answer






        New contributor




        Ali Bagheri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        answered 11 mins ago









        Ali BagheriAli Bagheri

        101




        101




        New contributor




        Ali Bagheri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        New contributor





        Ali Bagheri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        Ali Bagheri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Database Administrators Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f206002%2fhow-to-use-full-text-search-in-persian-using-postgresql%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            ف. موراي أبراهام

            صرب

            كأس إنترتوتو