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

Chapter 13 tsvector #28

Open
MatMel16 opened this issue Feb 17, 2021 · 5 comments
Open

Chapter 13 tsvector #28

MatMel16 opened this issue Feb 17, 2021 · 5 comments
Assignees

Comments

@MatMel16
Copy link

Hi,
I'm working on Win 10
I've installed PosgreSQL as described in book
I'm using version 4.28
Yes, I did download it from GitHub

When Running Listing 13-15 on page 231, chapter 13,
SELECT to_tsvector('I am walking across the sitting room to sit with you.');

pg gives me result:
'across':4 'am':2 'i':1 'room':7 'sit':9 'sitting':6 'the':5 'to':8 'walking':3 'with':10 'you':11
As long as I know, it is not, how tsvector should work, but instead should provide shortened version, for example: 'sit' :6,9

Im I doing something wrong?

@anthonydb
Copy link
Owner

Hello, @MatMel16 ... thank you for writing and for using my book.

I am fairly certain the issue is that your computer is set to a default text search configuration other than English. To check, you can run the following command in pgAdmin:

SHOW default_text_search_config;

If it displays a value other than English, that is the issue.

To get around this, you can modify Listing 13-15 like this:

SELECT to_tsvector('english', 'I am walking across the sitting room to sit with you.');

Please try that and let me know how it goes. Also, please let me know the results of the SHOW command above. Thanks!

@MatMel16
Copy link
Author

Hello,
thank you very much for the answer.
I enjoy your book very much.

After SHOW default_text_search_config; admin shows result: pg_catalog.simple

As you said, inserting english helped, but only for the simple issues as one, you listed.
For example for Listing 13-12 from your book:
SELECT president,
speech_date,
ts_headline(speech_text, to_tsquery('transportation & !roads'),
'StartSel = <,
StopSel = >,
MinWords=5,
MaxWords=7,
MaxFragments=1')
FROM president_speeches
WHERE search_speech_text @@ to_tsquery('english', 'transportation & !roads');

I observe 3 result.

  1. without stating 'english', as expected, I've got empty table
  2. Inserting 'english' in both tsqueries (in headline and where clause), I've got pretty confusing results (as in the picture below)
    image
  3. when I write it only into where clause, it seems to be most sufficient, but there is still one error. (Everything as it should be, but one row looks exatly like in previous result: "Mr. Speaker, Mr. Vice President")

@anthonydb
Copy link
Owner

Hmm, that's interesting. Would you please try something else? In your current pgAdmin session, run the following command:

SET default_text_search_config TO 'english';

That will set your text search language default to English -- but that won't be permanent. It's good only for your current session. If you start a new pgAdmin session, you'll have to run that again.

Try setting that default and running the queries as shown in the book. Please let me know the results.

Also, would you please report to me the result of this command?

show lc_ctype;

Thank you!

@MatMel16
Copy link
Author

Sure, the result of: show lc_ctype; is --> Slovak_Slovakia.1250

After I run the SET command, everything works as it should. Thank you. Is it somehow possible to set this permanent?

@anthonydb
Copy link
Owner

You're welcome.

Yes, you can make the change permanent by editing the value in your postgresql.conf file and re-starting PostgreSQL. Take a look at the section "Changing Server Settings" in Chapter 17. I mention the default search parameter in Listing 17-9.

Please let me know if you have any other questions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants