Skip to content

Instantly share code, notes, and snippets.

@xenda
Created May 24, 2010 20:29
Show Gist options
  • Save xenda/412388 to your computer and use it in GitHub Desktop.
Save xenda/412388 to your computer and use it in GitHub Desktop.
Table A
id name seccion_id sector_id
1 Coffee 1 10
2 Test2 1 10
3 Coffee 2 1
Table B
id name seccion_id sector_id
2 Test4 4 2
3 Coffee 2 5
4 Test6 5 3
Table C
id name
6 Coffee
8 Test9
9 Test10
# Using ThinkingSphinx:
ThinkingSphinx.search "Coffee"
> Sphinx Querying: 'Coffee'
> Sphinx (0.399761s) Found 04 results
Table A = 1,3
Table B = 3
Table C = 6
# However, now I just want those whose seccion_id is 2:
ThinkingSphinx.search "Coffee", :with=>{:seccion_id=>[2]}
# Expecting something like:
> Sphinx Querying: 'Coffee'
> Sphinx (0.440001s) Found 02 results
Table A = 3
Table B = 3
Table C = none (since it doesn't has a seccion_id column)
# However, got this:
> Sphinx Querying: 'Coffee'
> Sphinx (0.440001s) Found 03 results
Table A = 3
Table B = 3
Table C = 6 (even if it doesn't has seccion_id and would be filtered out)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment