Comments on: Using Sphinx search engine in Ruby on Rails https://kpumuk.info/ruby-on-rails/using-sphinx-search-engine-in-ruby-on-rails/ In my blog I'll try to describe about interesting technologies, my discovery in IT and some useful things about programming. Tue, 08 Sep 2015 00:22:30 +0000 hourly 1 https://wordpress.org/?v=6.6.1 By: Anatoliy https://kpumuk.info/ruby-on-rails/using-sphinx-search-engine-in-ruby-on-rails/comment-page-1/#comment-240316 Wed, 24 Sep 2008 15:23:26 +0000 http://kpumuk.info/projects/ror-plugins/using-sphinx-search-engine-in-ruby-on-rails/#comment-240316 Привет, всем!!!

Подскажите пожалуйста, как в sphinx реализовать такой же поиск, какой бы например был бы при ‘…LIKE %name%…’

Спасибо

]]>
By: tolya https://kpumuk.info/ruby-on-rails/using-sphinx-search-engine-in-ruby-on-rails/comment-page-1/#comment-238100 Fri, 12 Sep 2008 12:27:56 +0000 http://kpumuk.info/projects/ror-plugins/using-sphinx-search-engine-in-ruby-on-rails/#comment-238100 Спасибо большое за ответ.

Подскажите пожалуйста, как я могу в Sphinx изменить шаблон, по которому мне возвращается результат запроса?
Например в результате запроса: sphinx.Query(‘test’)
я хотел бы, чтоб в результате я мог бы получить кроме всего прочего: test16, test_12, [email protected].

Спасибо

]]>
By: Dmytro Shteflyuk https://kpumuk.info/ruby-on-rails/using-sphinx-search-engine-in-ruby-on-rails/comment-page-1/#comment-237953 Thu, 11 Sep 2008 12:51:51 +0000 http://kpumuk.info/projects/ror-plugins/using-sphinx-search-engine-in-ruby-on-rails/#comment-237953 Второй параметр метода Query – название индекса, по которому искать:

1
sphinx.Query('test', 'spaces_main');
]]>
By: tolya https://kpumuk.info/ruby-on-rails/using-sphinx-search-engine-in-ruby-on-rails/comment-page-1/#comment-237938 Thu, 11 Sep 2008 10:54:12 +0000 http://kpumuk.info/projects/ror-plugins/using-sphinx-search-engine-in-ruby-on-rails/#comment-237938 Привет, Всем!

У меня появился вопрос по Sphinx, помогите пожалуйста найти решение.

У меня есть следующая структура в конфигурационном файле:

sphinx.conf:

1
2
3
4
5
6
7
8
source sphinx_users_main
source sphinx_users_delta : sphinx_users_main
source sphinx_spaces_main
source sphinx_spaces_delta : sphinx_spaces_main
index users_main
index users_delta : users_main
index spaces_main
index spaces_delta : spaces_main

Такая структура была придумана мной для того, чтоб можно было при поиске получать ID по отдельной таблицы(указав по какому индексу с конфигурационного файла производить поиск).

Все, вроде как, корректно работает:

search -a test

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
Sphinx 0.9.8-release (r1371)
Copyright (c) 2001-2008, Andrew Aksyonoff

using config file '/usr/local/etc/sphinx.conf'...
index 'users_main': query 'test ': returned 14 matches of 14 total in 0.000 sec

displaying matches:
1. document=3592, weight=2
2. document=4178, weight=2
3. document=4179, weight=2
4. document=4181, weight=2
5. document=6192, weight=2
6. document=2807, weight=1
7. document=3593, weight=1
8. document=4717, weight=1
9. document=4740, weight=1
10. document=6090, weight=1
11. document=6196, weight=1
12. document=6218, weight=1
13. document=6219, weight=1
14. document=6220, weight=1

words:
1. 'test': 14 documents, 19 hits

index 'users_delta': query 'test ': returned 0 matches of 0 total in 0.000 sec

words:
1. 'test': 0 documents, 0 hits

index 'spaces_main': query 'test ': returned 17 matches of 17 total in 0.000 sec

displaying matches:
1. document=937, weight=1
2. document=940, weight=1
3. document=942, weight=1
4. document=943, weight=1
5. document=944, weight=1
6. document=945, weight=1
7. document=964, weight=1
8. document=983, weight=1
9. document=984, weight=1
10. document=985, weight=1
11. document=986, weight=1
12. document=987, weight=1
13. document=988, weight=1
14. document=989, weight=1
15. document=990, weight=1
16. document=991, weight=1
17. document=992, weight=1

words:
1. 'test': 17 documents, 17 hits

index 'spaces_delta': query 'test ': returned 0 matches of 0 total in 0.000 sec

words:
1. 'test': 0 documents, 0 hits

Но вот не могу понять, как с помощью Sphinx организовать поиск по указанному мной индексу, как например я это делаю с консоли:

search -i spaces_main -a test

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Sphinx 0.9.8-release (r1371)
Copyright (c) 2001-2008, Andrew Aksyonoff

using config file '/usr/local/etc/sphinx.conf'...
index 'spaces_main': query 'test ': returned 17 matches of 17 total in 0.000 sec

displaying matches:
1. document=937, weight=1
2. document=940, weight=1
3. document=942, weight=1
4. document=943, weight=1
5. document=944, weight=1
6. document=945, weight=1
7. document=964, weight=1
8. document=983, weight=1
9. document=984, weight=1
10. document=985, weight=1
11. document=986, weight=1
12. document=987, weight=1
13. document=988, weight=1
14. document=989, weight=1
15. document=990, weight=1
16. document=991, weight=1
17. document=992, weight=1

words:
1. 'test': 17 documents, 17 hits

Подскажите мне пожалуйста, как это можно организовать?

Спасибо

]]>
By: Ruboss - Overview of Architecture and Magic at Systems of Seven https://kpumuk.info/ruby-on-rails/using-sphinx-search-engine-in-ruby-on-rails/comment-page-1/#comment-236287 Thu, 04 Sep 2008 06:06:23 +0000 http://kpumuk.info/projects/ror-plugins/using-sphinx-search-engine-in-ruby-on-rails/#comment-236287 […] to embed into Ruboss (Heroku?) – Create Flex MXML templates for a Blog, Comments, Search (with Sphinx) Forum, Profile, Wiki, PhotoGallery, and Podcast Viewer. Bookmark It […]

]]>
By: Brad Folkens https://kpumuk.info/ruby-on-rails/using-sphinx-search-engine-in-ruby-on-rails/comment-page-1/#comment-95277 Mon, 10 Sep 2007 02:12:35 +0000 http://kpumuk.info/projects/ror-plugins/using-sphinx-search-engine-in-ruby-on-rails/#comment-95277
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Index: vendor/plugins/sphinx/lib/client.rb
===================================================================
--- vendor/plugins/sphinx/lib/client.rb (revision 5885)
+++ vendor/plugins/sphinx/lib/client.rb (working copy)
@@ -391,18 +391,20 @@
       count = response[p, 4].unpack('N*').first; p += 4
       
       # read matches
-      result['matches'] = {}
+      result['matches'] = []
       while count > 0 and p < max
         count -= 1
         doc, weight = response[p, 8].unpack('N*N*'); p += 8
   
-        result['matches'][doc] ||= {}
-        result['matches'][doc]['weight'] = weight
+        doc_data = {}
+        doc_data['weight'] = weight
         attrs_names_in_order.each do |attr|
           val = response[p, 4].unpack('N*').first; p += 4
-          result['matches'][doc]['attrs'] ||= {}
-          result['matches'][doc]['attrs'][attr] = val
+          doc_data['attrs'] ||= {}
+          doc_data['attrs'][attr] = val
         end
+        
+        result['matches'] << [doc, doc_data]
       end
       result['total'], result['total_found'], msecs, words = response[p, 16].unpack('N*N*N*N*'); p += 16
       result['time'] = '%.3f' % (msecs / 1000.0)
]]>
By: *oytss » Blog Archive » what a ruby (三) https://kpumuk.info/ruby-on-rails/using-sphinx-search-engine-in-ruby-on-rails/comment-page-1/#comment-48134 Sat, 19 May 2007 02:53:03 +0000 http://kpumuk.info/projects/ror-plugins/using-sphinx-search-engine-in-ruby-on-rails/#comment-48134 […] ActiveSearch Spinx indexed_search_engine SearchGenerator 一整個generator 另外,也可以做成Ajax real-time […]

]]>
By: Dmytro Shteflyuk https://kpumuk.info/ruby-on-rails/using-sphinx-search-engine-in-ruby-on-rails/comment-page-1/#comment-32945 Tue, 03 Apr 2007 16:04:05 +0000 http://kpumuk.info/projects/ror-plugins/using-sphinx-search-engine-in-ruby-on-rails/#comment-32945 joost, do you use set_filter_range in your code? Could you show me values you have sent to this method? Also it would be great, if you contact me directly to fix it quickly.

I’m updating API now and will upload it in next few days.

]]>
By: joost https://kpumuk.info/ruby-on-rails/using-sphinx-search-engine-in-ruby-on-rails/comment-page-1/#comment-32941 Tue, 03 Apr 2007 15:35:09 +0000 http://kpumuk.info/projects/ror-plugins/using-sphinx-search-engine-in-ruby-on-rails/#comment-32941 Currently I get the following error using the plugin (with v0.9.7 of Sphinx). All database fields are MySQL INT(11).

1
2
3
4
5
6
../config/../vendor/plugins/sphinx/lib/sphinx.rb:256:in 'pack': bignum too big to convert into 'unsigned long' (RangeError)
        from ../config/../vendor/plugins/sphinx/lib/sphinx.rb:256:in 'query'
        from ../config/../vendor/plugins/sphinx/lib/sphinx.rb:253:in 'each'
        from ../config/../vendor/plugins/sphinx/lib/sphinx.rb:253:in 'query'
        from ./test.rb:136:in 'search_entry'
        from ./test.rb:149

Any idea? Please let me know.. Also about an update!! :)

]]>
By: Dmytro Shteflyuk https://kpumuk.info/ruby-on-rails/using-sphinx-search-engine-in-ruby-on-rails/comment-page-1/#comment-31521 Tue, 27 Mar 2007 14:51:48 +0000 http://kpumuk.info/projects/ror-plugins/using-sphinx-search-engine-in-ruby-on-rails/#comment-31521 Update would be published tomorrow or the day after tomorrow. Currently I’m finishing RSpec tests which would cover whole functionality.

]]>