ThinkingSphinx::SphinxError: index part_price_record_core: query error: no field 'supplier_id' found in schema

308 views
Skip to first unread message

Viren

unread,
May 24, 2012, 9:04:04 AM5/24/12
to Thinking Sphinx
If Set up Thinking Sphinx on my application now

Everything was workinf fine

Until I decide to do a conditions query with Thinking Sphinx

PartPriceRecord.search "50002" ,:conditions => { :supplier_id =>
"supp50002" },:star => true

and it reported me with the above error

ThinkingSphinx::SphinxError: index part_price_record_core: query
error: no field 'supplier_id' found in schema

seeing even the Ryan Bates Screencast http://railscasts.com/episodes/120-thinking-sphinx
he seem to achieve the conditions clauses with "has" method defined
for the column

something like

has :author_id


Reading to one of the post by Pate Allen (scroll down to bottom)


https://groups.google.com/group/thinking-sphinx/browse_thread/thread/1dad41c934bfae41/bfe498c6266102b1?lnk=gst&q=+query+error%3A+no+field+#bfe498c6266102b1

" :with should be used for attribute filters, and :conditions for
field queries. "

so changing my above code with clause

PartPriceRecord.search "PartNumber50002",:with => {:supplier_id =>
"supp50002" },:star => true

and I get no result which is wrong as I can see Record for
"supplier_id" for part_number "PartNumber50002" in by database

Now I'm confuse

why is above error appearing and also what the fundamental difference
between "fields" and "attribute"

can anyone help

BTW here my indexes definition

define_index do
indexes part_number
has supplier_id
end

sphinx_scope(:supplier) { |name|
{:conditions => {:supplier_id => supplier}}
}

Pat Allan

unread,
May 24, 2012, 11:05:17 AM5/24/12
to thinkin...@googlegroups.com
Hi Viren

You should definitely be using :with (at the time of Ryan's screencast, Thinking Sphinx allowed for both field and attribute filters in :conditions, but that's no longer the case).

But also, if supplier_id is a string, then you can't filter on it when it's an attribute. Potentially, you would work around it, though it may be worth just making it a field instead:
http://freelancing-god.github.com/ts/en/common_issues.html#string_filters

As for the difference between fields and attributes - fields are the textual data that you generally expect your website's users to enter, whereas attributes are usually not strings, and are used for internal filters and sorting. There's a bit more of an explanation here:
http://freelancing-god.github.com/ts/en/sphinx_basics.html

Cheers

--
Pat
> --
> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> To post to this group, send email to thinkin...@googlegroups.com.
> To unsubscribe from this group, send email to thinking-sphi...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.
>

Viren

unread,
May 24, 2012, 12:55:57 PM5/24/12
to Thinking Sphinx
Thanks Point noted
But just to confirm you said "You should definitely be using :with"
and "supplier_id is a string, then you can't filter on it when it's an
attribute."

so that take "with" out of the picture can I use conditions now apart
for that amazing hack you just mention in the link

and why did the conditions at first place blew so badly .


Can you comment on it

Thanks



On May 24, 8:05 pm, Pat Allan <p...@freelancing-gods.com> wrote:
> HiViren
>
> You should definitely be using :with (at the time of Ryan's screencast, Thinking Sphinx allowed for both field and attribute filters in :conditions, but that's no longer the case).
>
> But also, if supplier_id is a string, then you can't filter on it when it's an attribute. Potentially, you would work around it, though it may be worth just making it a field instead:http://freelancing-god.github.com/ts/en/common_issues.html#string_fil...
>
> As for the difference between fields and attributes - fields are the textual data that you generally expect your website's users to enter, whereas attributes are usually not strings, and are used for internal filters and sorting. There's a bit more of an explanation here:http://freelancing-god.github.com/ts/en/sphinx_basics.html
>
> Cheers
>
> --
> Pat
>
> On 24/05/2012, at 11:04 PM,Virenwrote:
>
>
>
>
>
>
>
> > If Set up Thinking Sphinx on my application now
>
> > Everything was workinf fine
>
> > Until I decide to do a conditions query with Thinking Sphinx
>
> > PartPriceRecord.search "50002" ,:conditions => { :supplier_id =>
> > "supp50002" },:star => true
>
> > and it reported me with the above error
>
> > ThinkingSphinx::SphinxError: index part_price_record_core: query
> > error: no field 'supplier_id' found in schema
>
> > seeing even the Ryan Bates Screencasthttp://railscasts.com/episodes/120-thinking-sphinx
> > he seem to achieve the conditions clauses with "has" method defined
> > for the column
>
> > something like
>
> > has :author_id
>
> > Reading to one of the post by Pate Allen (scroll down to bottom)
>
> >https://groups.google.com/group/thinking-sphinx/browse_thread/thread/...

Pat Allan

unread,
Jun 6, 2012, 5:03:43 PM6/6/12
to thinkin...@googlegroups.com
Sorry, just to be clear: :with is for attributes, and :conditions is for fields.

This wasn't always the case (in old versions of Thinking Sphinx, filters for both fields and attributes could be in :conditions), but all recent releases require them to be separated into :with and :conditions appropriately.

Now, specific to your case, supplier_id seems to be a string - and string attributes cannot be filtered on. If you change it to a field, then perhaps you can filter on it using :conditions - but you're also dealing with Sphinx's query language and word token parsing there, which can sometimes get in the way.

Hope this helps.

--
Pat

Virendra Negi

unread,
Jun 7, 2012, 1:26:47 AM6/7/12
to thinkin...@googlegroups.com
Thanks Pat ,
      Truly appreciated
Reply all
Reply to author
Forward
0 new messages