Thanks, I figured some thing. I was trying ti use float for latitude and longitude. But sphinx wants radians. so now I have indexes 'RADIANS(st_x(location_geom)), :as => 'lat' group_by 'lat'
This works for me. thanks pat On Wed, Sep 2, 2009 at 10:01 AM, Pat Allan <p...@freelancing-gods.com> wrote: > > Hi Sumeet > > The problem is that you're trying to filter by a string attribute, > which Sphinx doesn't allow at this point in time. > > If you just want results where the search on that column can match any > word you're providing, then setting it as a field instead of an > attribute will work: > indexes location_text > > WorkingAsset.search(:conditions => {:location_text => 'logan'}) > > If you want to have *exact* matches on string values for filters, then > you'll need to do something like this: > has 'crc32(location_text)', :as => :location_text, :type => :integer > > WorkingAsset.search(:with => {:location_text => 'logan'.to_crc32}) > > Cheers > > -- > Pat > > On 01/09/2009, at 10:48 PM, sumeet panchal wrote: > > > > > please help? > > > > On Sep 1, 2:41 pm, sumeet panchal <sumiz.wo...@gmail.com> wrote: > >> sorry I was using key word 'harry' not 'sumeet' > >> > >> On Sep 1, 2:38 pm, sumeet panchal <sumiz.wo...@gmail.com> wrote: > >> > >>> Hi Pat, > >> > >>> define_index do > >>> indexes :name > >>> has location_text, :type => :string > >>> set_property :delta => true > >>> end > >> > >>> this is my model. I do rake ts:config the rake ts:rebuild > >>> Now I do search like : > >> > >>> a = WorkingAsset.search('sumeet', :with => {:location_text => > >>> 'logan'}) > >> > >>> But It give me improper results gave me results whose :location_text > >>> is "" (blank not logan) > >>> My location_text is column with type text in database. > >>> I don't know why it is throwing this error I tried indexes also for > >>> the same. And it is doing it for all the attributes > >>> I try to add. Please can u solve this strange error. > >> > >>> [#<WorkingAsset id: 80819, name: "Sachin harry 2", description: "", > >>> external_url: "", copyrighted: false, copyright_holder: "", > >>> copyright_date: "", usage_rights: "", usage_conditions: "", > >>> download_restriction: nil, creative_commons_license_id: nil, source: > >>> "", credits: "", location_text: "", delta: false, created_at: > >>> "2009-08-02 20:50:20", updated_at: "2009-08-02 20:50:38", > >>> location_geom: nil, location_state: "", file_id: 18094>, > >>> #<WorkingAsset id: 80821, name: "sumeet harry ", description: "", > >>> external_url: "", copyrighted: false, copyright_holder: "", > >>> copyright_date: "", usage_rights: "", usage_conditions: "", > >>> download_restriction: nil, creative_commons_license_id: nil, source: > >>> "", credits: "", location_text: "", delta: false, created_at: > >>> "2009-08-02 22:47:28", updated_at: "2009-08-02 22:47:48", > >>> location_geom: nil, location_state: "", file_id: 18096>] > >> > >>> this were the results. > >> > >>> Thanks > >>> On Aug 31, 12:50 pm, sumeet panchal <sumiz.wo...@gmail.com> wrote: > >> > >>>> Thanks Pat. > >> > >>>> On Mon, Aug 31, 2009 at 12:05 PM, Pat Allan <p...@freelancing- > >>>> gods.com>wrote: > >> > >>>>> Yes, you can (at this point in time) only have one define_index > >>>>> per > >>>>> model. > >> > >>>>> Also, make sure you stop Sphinx, reindex, and then restart Sphinx > >>>>> whenever you change your index structure. > >> > >>>>> -- > >>>>> Pat > >> > >>>>> On 31/08/2009, at 7:03 PM, sumeet panchal wrote: > >> > >>>>>> include AssetCommons // this one don't have define_index > >>>>>> include ManagedContent // this do have a define_index > >>>>>> define_index do > >>>>>> indexes :name > >>>>>> indexes :location_geom, :type=>:string > >>>>>> set_property :delta => true > >>>>>> end > >> > >>>>>> I think this error is due to the fact I was having two > >>>>>> define_index > >>>>>> by mistake. And If I fix it this should work. > >>>>>> Your comment will be valuable for me. > >> > >>>>>> Thanks > >> > >>>>>> On Mon, Aug 31, 2009 at 11:52 AM, Pat Allan <p...@freelancing- > >>>>>> gods.com> wrote: > >> > >>>>>> What's the full contents of your define_index block in > >>>>>> WorkingAsset? > >> > >>>>>> -- > >>>>>> Pat > >> > >>>>>> On 31/08/2009, at 6:49 PM, sumeet panchal wrote: > >> > >>>>>>> Hi Pat, > >> > >>>>>>> But Can you please tell me why I get that error for incompatible > >>>>>>> schema. > >> > >>>>>>> Thanks > >> > >>>>>>> On Sun, Aug 30, 2009 at 3:37 PM, Pat Allan <p...@freelancing- > >>>>>>> gods.com> wrote: > >> > >>>>>>> Hi Sumeet > >> > >>>>>>> It looks like you're using a custom library for PostgreSQL, > >>>>>>> and I'm > >>>>>>> not even that experienced with that database system, so this > >>>>>>> is all > >>>>>>> guesswork, but we need to return each point. > >> > >>>>>>> Would something like the following work? > >> > >>>>>>> has 'RADIANS(st_x(st_astest(location_geom)))', :as > >>>>>>> => :latitude, :type => :float > >>>>>>> has 'RADIANS(st_y(st_astest(location_geom)))', :as > >>>>>>> => :longitude, :type => :float > >> > >>>>>>> I'm not sure if I'm using the right methods, but you'll need > >>>>>>> to do > >>>>>>> something like that to get it working with Sphinx. > >> > >>>>>>> -- > >>>>>>> Pat > >> > >>>>>>> On 29/08/2009, at 7:43 PM, sumeet panchal wrote: > >> > >>>>>>>> Hi, > >> > >>>>>>>> This is data normally in my column > >>>>>>>> (0101000020AD1000000000000000C041406666666666D65CC0) its a > >>>>>> geometry > >>>>>>>> point. > >>>>>>>> and when I did this : > >>>>>>>> select st_astext(location_geom) from <table> where id=1; > >>>>>>>> It gives: POINT(35.5 -115.35). > >>>>>>>> this is type for column: location_geom :geometry point, 4269 > >>>>>>>> biggest problem I am facing the error: > >>>>>>>> ERROR: index 'working_asset_core': incompatible schemas: > >>>>>>>> attribute > >>>>>>>> count mismatch: 4 in schema 'working_asset_core_1', 5 in schema > >>>>>>>> 'working_asset_core_0'. Whenever I try to add the attribute to > >>>>>>>> define_index it gives me this error. > >> > >>>>>>>> thanks > >> > >>>>>>>> On Aug 29, 3:32 am, Pat Allan <p...@freelancing-gods.com> > >>>>>>>> wrote: > >>>>>>>>> Hi Sumeet > >> > >>>>>>>>> Can you give us an example of the data inside that column? > >>>>>>>>> Then I > >>>>>>>>> might be able to suggest a SQL snippet to extract latitude and > >>>>>>>>> longitude out for attributes. > >> > >>>>>>>>> -- > >>>>>>>>> Pat > >> > >>>>>>>>> On 29/08/2009, at 12:54 AM, sumeet panchal wrote: > >> > >>>>>>>>>> hi I am struggling with this for so long. > >> > >>>>>>>>>> I have a field named location_geom : (geometry point). It > >>>>>>>>>> have > >>>>>>>>>> latitude and longitude. It stores value using georuby. > >>>>>>>>>> So we can have methods like lat lon x y on it. > >>>>>>>>>> Problem is that I want an attribute from it > >> > >>>>>>>>>> What I did is > >> > >>>>>>>>>> define_index > >>>>>>>>>> indexes :name > >>>>>>>>>> has "location_geom.lat" , :as => :latitude, :type => :float > >>>>>>>>>> end > >> > >>>>>>>>>> I need to index this field, if possible separately in > >>>>>>>>>> latitude > >>>>>> and > >>>>>>>>>> longitude. > >>>>>>>>>> please help. > >> > >>>>>>>>>> And I also get an error again and again in indexing it is: > >>>>>>>>>> when i do rake ts:in > >> > >>>>>>>>>> ERROR: index 'working_asset_core': incompatible schemas: > >>>>>> attribute > >>>>>>>>>> count mismatch: 4 in schema 'working_asset_core_1', 5 in > >>>>>>>>>> schema > >>>>>>>>>> 'working_asset_core_0'. > >> > >>>>>>>>>> what is cause and solution for this. > >>>>>>>>>> Please Help. > >> > >>>>>>>>>> Thanks > >>>>>>>>>> Sumeet > >> > >> > > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group. To post to this group, send email to thinking-sphinx@googlegroups.com To unsubscribe from this group, send email to thinking-sphinx+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en -~----------~----~----~----~------~----~------~--~---