Hi Joan
City should be a field, not an attribute - so switch 'has city' to 'indexes
city' and see if that helps matters.
Cheers
--
Pat
On 12/11/2011, at 2:15 AM, Joan Ruiz wrote:
> Hi Pat, thanks for the quick reply
>
> I did read the wild cards example and created my config/sphinx.yml
> with this data:
>
> development:
> enable_star: 1
> min_infix_length: 3
>
> But seems like the star is not working properly. I'm doing this search
>
> params = {:generic_text => "Michael", :city => "Dall"}
> Client.search params[:generic_search], :conditions => {:city =>
> "#{params[:city]}*"}
>
> but it is returning clients from many cities like Medellin, Dallas and
> Madrid (Those are the cities I have on my DB at this moment).
>
> Also, I tried these searches on console and they didn't found the
> client
>
> ruby-1.9.2-p290 :001 > Client.search "mich*"
> Sphinx Query (1.8ms) mich*
> Sphinx Found 0 results
> => []
> ruby-1.9.2-p290 :002 > Client.search "*mich*"
> Sphinx Query (1.9ms) *mich*
> Sphinx Found 0 results
> => []
>
>
> my indexes are
>
> define_index do
> indexes :name
> indexes registered_name
> indexes contacts.name, :as => :contact
> has city
> has created_at
> end
>
> I checked the file development.sphinx.config and looks like this
>
> source client_core_0
> {
> type = mysql
> sql_host = localhost
> sql_user = my_user
> sql_pass = my_secret_password
> sql_db = Proyect_development
> sql_sock = /var/run/mysqld/mysqld.sock
> sql_query_pre = SET NAMES utf8
> sql_query_pre = SET TIME_ZONE = '+0:00'
> sql_query = SELECT SQL_NO_CACHE `clients`.`id` * CAST(1 AS SIGNED) +
> 0 AS `id` , `clients`.`name` AS `name`, `clients`.`registered_name` AS
> `registered_name`, GROUP_CONCAT(DISTINCT IFNULL(`contacts`.`name`,
> '0') SEPARATOR ' ') AS `contact`, `clients`.`id` AS
> `sphinx_internal_id`, 0 AS `sphinx_deleted`, 3236430179 AS
> `class_crc`, UNIX_TIMESTAMP(`clients`.`created_at`) AS `created_at`,
> IFNULL(`clients`.`city`, '') AS `city` FROM `clients` LEFT OUTER JOIN
> `contacts` ON `contacts`.`client_id` = `clients`.`id` WHERE
> (`clients`.`id` >= $start AND `clients`.`id` <= $end) GROUP BY
> `clients`.`id` ORDER BY NULL
> sql_query_range = SELECT IFNULL(MIN(`id`), 1), IFNULL(MAX(`id`), 1)
> FROM `clients`
> sql_attr_uint = sphinx_internal_id
> sql_attr_uint = sphinx_deleted
> sql_attr_uint = class_crc
> sql_attr_timestamp = created_at
> sql_attr_str2ordinal = city
> sql_query_info = SELECT * FROM `clients` WHERE `id` = (($id - 0) /
> 1)
> }
>
> index client_core
> {
> source = client_core_0
> path = /home/curien/work/proyect/db/sphinx/development/client_core
> charset_type = utf-8
> enable_star = 1
> }
>
> Do you have any idea what could be the problem?
>
> Thanks for your time and help
>
> Joan
>
> On Nov 11, 12:23 am, Pat Allan <[email protected]> wrote:
>> Hi Joan
>>
>> You will want to use :with for the date range - and then you'll need
>> wildcards for the city matching. You can find the relevant settings
>> here:http://freelancing-god.github.com/ts/en/common_issues.html#wildcards
>>
>> And so your query will become:
>>
>> Client.search params[:generic_text],
>> :conditions => {:city => "*#{params[:city]*"},
>> :with => {:created_at => params[:start_date]..params[:end_date]}
>>
>> Although you'll want to make sure params[:start_date] and params[:end_date]
>> are actually Time objects.
>>
>> Cheers
>>
>> --
>> Pat
>>
>> On 11/11/2011, at 12:14 PM, Joan Ruiz wrote:
>>
>>
>>
>>
>>
>>
>>
>>> Hello
>>
>>> I have a search form with 4 text fields: generic text, city, start
>>> date and end date. Generic text uses TS to search on name, registered
>>> name and contact's name and I need a query like this:
>>
>>> Client.search("params[:generic_text]", :conditions => ["city like ?
>>> and created_at > ? and created_at < ?", "%params[:city]%",
>>> params[:start_date], params[:end_date]])
>>
>>> I have seen that I can use :with to search on the range of dates, but
>>> I can't find something similar to "city like ?"
>>> Am I missing something? Any help would be really appreciated
>>
>>> These are my indexes on the Client model
>>
>>> define_index do
>>> indexes :name
>>> indexes registered_name
>>> indexes contacts.name, :as => :contact
>>> has :country
>>> has :created_at
>>> end
>>
>>> pd: sorry for the bad English
>>
>>> --
>>> 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
>>> athttp://groups.google.com/group/thinking-sphinx?hl=en.
>
> --
> 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.
>
--
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.