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

Ad hoc search using RUM indexes #74

Open
rudibroekhuizen opened this issue Nov 15, 2019 · 6 comments
Open

Ad hoc search using RUM indexes #74

rudibroekhuizen opened this issue Nov 15, 2019 · 6 comments

Comments

@rudibroekhuizen
Copy link

rudibroekhuizen commented Nov 15, 2019

I was wondering how to set up ad hoc search using RUM indexes. For example, I have a table with three columns. I would like to search combinations of the fields. When creating a tsvector column, using all columns the content of the fields are combined, so I can not force to search only one field.

timestamp species location
2019-11-04 Buteo buteo Texel
2019-10-03 Haliaeetus albicilla Werkendam
2019-10-01 Athene noctua Zwolle

Should I create tsvector columns for column 'species', and a seperate tsvector column for 'location' and use a query like this:

SELECT *
FROM mytable
WHERE timestamp BETWEEN '2019-11-01T13:00:00.000Z' AND '2019-11-15T13:00:00.000'
AND tsv_species @@ websearch_to_tsquery('simple','Buteo')
AND tsv_location @@ websearch_to_tsquery('simple','Texel or Zwolle')
ORDER BY by observation_timestamp <=| '2019-11-15T13:00:00.000';

Or are there better options? For example, can I use multiple rum_tsvector_addon_ops arguments when creating a RUM index?

@obartunov
Copy link

obartunov commented Nov 15, 2019 via email

@rudibroekhuizen
Copy link
Author

I thought weight labels could only be used using a GIN index, can they also be used with a RUM index?

@obartunov
Copy link

obartunov commented Nov 16, 2019 via email

@akorotkov
Copy link
Contributor

BTW, in spite of GIN weights are present in RUM index posting lists and could be used for filtering within the index.

@obartunov
Copy link

obartunov commented Nov 16, 2019 via email

@rudibroekhuizen
Copy link
Author

Thanks. I did some testing with weights, but it doesn't seem to work with websearch_to_tsquery, only in combination with to_tsquery. Another thing is that the set_weight setting only works when using at most 4 columns (A,B,C,D), so if I want to search more than four, it is not possible. Maybe create tsv columns per column? Concat them all to search in any field?

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

No branches or pull requests

3 participants