What's in your development.sphinx.conf file? -- Pat
On 26/05/2009, at 11:57 AM, Mickaël wrote: > > Hi Pat, > > Yes, when I'm searching with 'search' tool, or with TS (without > filters), the result is equal. > > When I'm searching with filter (:ts_forum_posts_ids) TS don't threat > the foreign_key post_id NULL. > > On 26 mai, 20:51, Pat Allan <[email protected]> wrote: >> Hi Mickaël >> >> Hmm, not entirely sure what the problem is yet - but just so you >> know, >> Sphinx treats NULLs in attributes as 0's. >> >> If you remove the filters, do you get the same results as using the >> 'search' command-line tool? >> >> -- >> Pat >> >> On 26/05/2009, at 9:19 AM, Mickaël Allain wrote: >> >>> Hi everybody, >> >>> I want to index and search over a class model (include has filter) >>> which could be like this. >> >>> class ForumPost < ActiveRecord::Base >>> validates_presence_of :title, :content >> >>> belongs_to :forum_section, :foreign_key=> :section_id >>> belongs_to :forum_post, :foreign_key=> :post_id >>> >>> has_many :forum_posts,:foreign_key=> :post_id, :dependent=>:destroy >>> belongs_to :user >> >>> xss_terminate :html5lib_sanitize => [ :content ] >> >>> # Definition de l index de recherche >>> define_index do >>> # General (Mots cles / Nom du forum / Sous-Forum Categorie / >>> Auteur / Nombre de reponses) >>> indexes title, :as => :ts_forum_post_title >>> indexes content, :as => :ts_forum_post_content >> >>> has forum_post(:id), :as => :ts_forum_post_ids >> >>> # Propriete sur les recherches >>> set_property :enable_star => 1 >>> set_property :min_prefix_len => 1 >> >>> end >>> end >> >>> If the ForumPost is the TOPIC, they don't have forum_post value >>> (NULL value), and their reply forum_post value will be the TOPIC ID. >> >>> To be more clear, an example of my database >> >>> "id >>> ";"title >>> ";"content >>> ";"user_id";"section_id";"post_id";"created_at";"updated_at" >>> "41";"TOPIC";"<p>cvxcvxcvcx<br/></p>";"11";"15";NULL;"2009-05-06 >>> 10:01:07";"2009-05-06 10:01:07" >>> "44";"reply_1";"<p>cxvxv<br/></p>";"11";"15";"41";"2009-05-06 >>> 10:01:50";"2009-05-06 10:01:50" >>> "45";"reply_2";"<p>vxvcxvxc<br/></p>";"11";"15";"41";"2009-05-06 >>> 10:02:10";"2009-05-06 10:02:10" >> >>> When i'm searching for "cx*" in Search client, the result is good >> >>> search --config /home/gamez/project/uneek/trunk/config/ >>> development.sphinx.conf cx* >> >>> displaying matches: >>> 1. document=410, weight=1, ts_forum_post_ids=41, >>> sphinx_internal_id=41, class_crc=3624676887, >>> subclass_crcs=(3624676887), sphinx_deleted=0 >>> id=41 >>> title=TOPIC >>> content=<p>cvxcvxcvcx<br/></p> >>> user_id=11 >>> section_id=15 >>> post_id=(NULL) >>> created_at=2009-05-06 10:01:07 >>> updated_at=2009-05-06 10:01:07 >>> 2. document=440, weight=1, ts_forum_post_ids=44, >>> sphinx_internal_id=44, class_crc=3624676887, >>> subclass_crcs=(3624676887), sphinx_deleted=0 >>> id=44 >>> title=reply_1 >>> content=<p>cxvxv<br/></p> >>> user_id=11 >>> section_id=15 >>> post_id=41 >>> created_at=2009-05-06 10:01:50 >>> updated_at=2009-05-06 10:01:50 >>> 3. document=440, weight=1, ts_forum_post_ids=45, >>> sphinx_internal_id=45, class_crc=3624676887, >>> subclass_crcs=(3624676887), sphinx_deleted=0 >>> id=45 >>> title=reply_2 >>> content=<p>vxvcxvxc<br/></p> >>> user_id=11 >>> section_id=15 >>> post_id=41 >>> created_at=2009-05-06 10:01:50 >>> updated_at=2009-05-06 10:01:50 >> >>> words: >>> 1. 'cx*': 3 documents, 6 hits >> >>> But, With, thinkingSphinx search and has filter, the result is >>> wrong. >> >>> @searches = ThinkingSphinx::Search.search(params[:search] >>> [:query], :per_page => self.per_page, :classes => [UserProfile, >>> Community, Article, Event, Forum, Blog, BlogPost, BlogComment, >>> Forum, ForumPost, ForumSection], :with => { >>> :ts_community_ids => >>> communities_ids_from_user(current_user.id), >>> :ts_blog_comments_ids => >>> blog_comments_ids_from_user(current_user.id), >>> :ts_blog_post_ids => >>> blog_posts_ids_from_user(current_user.id), >>> :ts_blog_ids => blog_ids_from_user(current_user.id), >>> :ts_forum_ids => forum_ids_from_user(current_user.id), >>> :ts_forum_post_ids => >>> forum_post_ids_from_user(current_user.id), >>> :ts_forum_section_ids => >>> forum_section_ids_from_user(current_user.id) >>> } >>> ) >> >>> The :ts_forum_post_ids value is [36, 41, 44, 45, 63, 64] but, Sphinx >>> search, doesn't include 41 ID Document >> >>> /* Mongrel Log */ >>> Sphinx: cx* >>> Sphinx Result: [44, 45] >> >>> But, if I delete the line, and search like this >> >>> @searches = ThinkingSphinx::Search.search(params[:search] >>> [:query], :per_page => self.per_page, :classes => [UserProfile, >>> Community, Article, Event, Forum, Blog, BlogPost, BlogComment, >>> Forum, ForumPost, ForumSection], :with => { >>> :ts_community_ids => >>> communities_ids_from_user(current_user.id), >>> :ts_blog_comments_ids => >>> blog_comments_ids_from_user(current_user.id), >>> :ts_blog_post_ids => >>> blog_posts_ids_from_user(current_user.id), >>> :ts_blog_ids => blog_ids_from_user(current_user.id), >>> :ts_forum_ids => forum_ids_from_user(current_user.id), >>> :ts_forum_section_ids => >>> forum_section_ids_from_user(current_user.id) >>> } >>> ) >> >>> The result is good. >> >>> I think TS ignore docs when NULLABLE belongs_to is present and when >>> we using has keyword. Do you have some idea to fix them ? or i'm >>> doing something wrong ? >> >>> Thank's. >> >>> Best regards, >> >>> Mickaël ALLAIN. >> >> > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en -~----------~----~----~----~------~----~------~--~---
