Judking
Judking

Reputation: 6371

Some problems on sphinx for Java API

I'm new to sphinx, and I've encountered a few problems:

$1 After setting max_matches = 200 in class searchd in csft.conf, I called

org.sphx.api.test.main(new String[]{"-h", "127.0.0.1","-i", "magnet","-p", "9312", "-l", "100", "keyword"});

in a java main method. The error returned is

Error: searchd error: per-query max_matches=1000 out of bounds (per-server max_matches=200)

As you can see, I've added the param: -l = 100, what else should I set to prevent this error in Java?

$2 I want to use sortMode = SphinxClient.SPH_SORT_TIME_SEGMENTS to have the search result ordering by time desc. My attribute is written like this in csft.conf:

sql_attr_timestamp=UNIX_TIMESTAMP(upload_time) as dt

Could anyone tell me how can I set the attribute in Java code? I've tried to set the sortClause String in java, but it always said that Attribute XXX has not been found.

$3 I want to know whether SphinxClient in Java is thread safe, becaust I don't like to create a SphinxClient instance every time a person do a query.

Thanks in advance!

Upvotes: 0

Views: 504

Answers (1)

barryhunter
barryhunter

Reputation: 21091

  1. If the class you are using is https://code.google.com/p/sphinxtools/source/browse/trunk/src/org/sphx/test/test.java?r=2 then the function never even inspects 'argv'. It hardcodes all the variables. There is nothing passed as the third param to setLimits
  2. sql_attr_timestamp simply accepts a column name, no functions or anything. The function call HAS to be in the main sql_query
  3. My java is very rusty, but would have to say no. It stores all sort of state in private varibles. Multiple threads using the client at once will clober them.

Upvotes: 1

Related Questions