Skip to content

Commit

Permalink
merged rel20 branch (upto r3135) back into trunk
Browse files Browse the repository at this point in the history
git-svn-id: http://sphinxsearch.googlecode.com/svn/trunk@3136 8b96e2b9-35c5-2c16-bc47-5122d61876d4
  • Loading branch information
tomat committed Mar 2, 2012
1 parent f47583b commit 82a5ca1
Show file tree
Hide file tree
Showing 27 changed files with 346 additions and 203 deletions.
10 changes: 8 additions & 2 deletions api/java/SphinxClient.java
Expand Up @@ -42,7 +42,8 @@ public class SphinxClient
public final static int SPH_RANK_MATCHANY = 5;
public final static int SPH_RANK_FIELDMASK = 6;
public final static int SPH_RANK_SPH04 = 7;
public final static int SPH_RANK_TOTAL = 8;
public final static int SPH_RANK_EXPR = 8;
public final static int SPH_RANK_TOTAL = 9;

/* sorting modes */
public final static int SPH_SORT_RELEVANCE = 0;
Expand Down Expand Up @@ -193,6 +194,7 @@ public SphinxClient(String host, int port)
_indexWeights = new LinkedHashMap();
_fieldWeights = new LinkedHashMap();
_ranker = SPH_RANK_PROXIMITY_BM25;
_rankexpr = "";

_overrideTypes = new LinkedHashMap();
_overrideValues = new LinkedHashMap();
Expand Down Expand Up @@ -504,9 +506,10 @@ public void SetMatchMode(int mode) throws SphinxException
}

/** Set ranking mode. */
public void SetRankingMode ( int ranker ) throws SphinxException
public void SetRankingMode ( int ranker, String rankexpr ) throws SphinxException
{
myAssert ( ranker>=0 && ranker<SPH_RANK_TOTAL, "unknown ranker value; use one of the SPH_RANK_xxx constants" );
_rankexpr = ( rankexpr==null ) ? "" : rankexpr;
_ranker = ranker;
}

Expand Down Expand Up @@ -819,6 +822,9 @@ public int AddQuery ( String query, String index, String comment ) throws Sphinx
out.writeInt(_limit);
out.writeInt(_mode);
out.writeInt(_ranker);
if ( _ranker == SPH_RANK_EXPR ) {
writeNetUTF8(out, _rankexpr);
}
out.writeInt(_sort);
writeNetUTF8(out, _sortby);
writeNetUTF8(out, query);
Expand Down
12 changes: 9 additions & 3 deletions api/libsphinxclient/sphinxclient.c
Expand Up @@ -159,6 +159,7 @@ struct st_sphinx_client
const char ** index_weights_names;
const int * index_weights_values;
int ranker;
const char * rankexpr;
int max_query_time;
int num_field_weights;
const char ** field_weights_names;
Expand Down Expand Up @@ -240,6 +241,7 @@ sphinx_client * sphinx_create ( sphinx_bool copy_args )
client->index_weights_names = NULL;
client->index_weights_values = NULL;
client->ranker = SPH_RANK_DEFAULT;
client->rankexpr = NULL;
client->max_query_time = 0;
client->num_field_weights = 0;
client->field_weights_names = NULL;
Expand Down Expand Up @@ -523,15 +525,16 @@ sphinx_bool sphinx_set_match_mode ( sphinx_client * client, int mode )
}


sphinx_bool sphinx_set_ranking_mode ( sphinx_client * client, int ranker )
sphinx_bool sphinx_set_ranking_mode ( sphinx_client * client, int ranker, const char * rankexpr )
{
if ( !client || ranker<SPH_RANK_PROXIMITY_BM25 || ranker>SPH_RANK_SPH04 ) // FIXME?
if ( !client || ranker<SPH_RANK_PROXIMITY_BM25 || ranker>=SPH_RANK_TOTAL ) // FIXME?
{
set_error ( client, "invalid arguments (ranking mode %d out of bounds)", ranker );
return SPH_FALSE;
}

client->ranker = ranker;
client->rankexpr = strchain ( client, rankexpr );
return SPH_TRUE;
}

Expand Down Expand Up @@ -959,7 +962,8 @@ static int calc_req_len ( sphinx_client * client, const char * query, const char
+ safestrlen ( client->group_by )
+ safestrlen ( client->group_sort )
+ safestrlen ( client->group_distinct )
+ safestrlen ( comment );
+ safestrlen ( comment )
+ safestrlen ( client->rankexpr );

filter_val_size = ( client->ver_search>=0x114 ) ? 8 : 4;
for ( i=0; i<client->num_filters; i++ )
Expand Down Expand Up @@ -1091,6 +1095,8 @@ int sphinx_add_query ( sphinx_client * client, const char * query, const char *
send_int ( &req, client->limit );
send_int ( &req, client->mode );
send_int ( &req, client->ranker );
if ( client->ranker==SPH_RANK_EXPR )
send_str ( &req, client->rankexpr );
send_int ( &req, client->sort );
send_str ( &req, client->sortby );
send_str ( &req, query );
Expand Down
5 changes: 4 additions & 1 deletion api/libsphinxclient/sphinxclient.h
Expand Up @@ -52,6 +52,9 @@ enum
SPH_RANK_MATCHANY = 5,
SPH_RANK_FIELDMASK = 6,
SPH_RANK_SPH04 = 7,
SPH_RANK_EXPR = 8,
SPH_RANK_TOTAL = 9,


SPH_RANK_DEFAULT = SPH_RANK_PROXIMITY_BM25
};
Expand Down Expand Up @@ -200,7 +203,7 @@ sphinx_bool sphinx_close ( sphinx_client * client );
sphinx_bool sphinx_set_limits ( sphinx_client * client, int offset, int limit, int max_matches, int cutoff );
sphinx_bool sphinx_set_max_query_time ( sphinx_client * client, int max_query_time );
sphinx_bool sphinx_set_match_mode ( sphinx_client * client, int mode );
sphinx_bool sphinx_set_ranking_mode ( sphinx_client * client, int ranker );
sphinx_bool sphinx_set_ranking_mode ( sphinx_client * client, int ranker, const char * rankexpr );
sphinx_bool sphinx_set_sort_mode ( sphinx_client * client, int mode, const char * sortby );
sphinx_bool sphinx_set_field_weights ( sphinx_client * client, int num_weights, const char ** field_names, const int * field_weights );
sphinx_bool sphinx_set_index_weights ( sphinx_client * client, int num_weights, const char ** index_names, const int * index_weights );
Expand Down
23 changes: 20 additions & 3 deletions api/ruby/lib/sphinx/client.rb
Expand Up @@ -107,6 +107,10 @@ class Client
SPH_RANK_WORDCOUNT = 3
# phrase proximity
SPH_RANK_PROXIMITY = 4
SPH_RANK_MATCHANY = 5
SPH_RANK_FIELDMASK = 6
SPH_RANK_SPH04 = 7
SPH_RANK_EXPR = 8

# Known sort modes

Expand Down Expand Up @@ -195,6 +199,7 @@ def initialize
@anchor = [] # geographical anchor point
@indexweights = [] # per-index weights
@ranker = SPH_RANK_PROXIMITY_BM25 # ranking mode (default is SPH_RANK_PROXIMITY_BM25)
@rankexpr = '' # ranker expression for SPH_RANK_EXPR
@maxquerytime = 0 # max query time, milliseconds (default is 0, do not limit)
@fieldweights = {} # per-field-name weights
@overrides = [] # per-query attribute values overrides
Expand Down Expand Up @@ -265,14 +270,19 @@ def SetMatchMode(mode)
end

# Set ranking mode.
def SetRankingMode(ranker)
def SetRankingMode(ranker, rankexpr = '')
assert { ranker == SPH_RANK_PROXIMITY_BM25 \
|| ranker == SPH_RANK_BM25 \
|| ranker == SPH_RANK_NONE \
|| ranker == SPH_RANK_WORDCOUNT \
|| ranker == SPH_RANK_PROXIMITY }
|| ranker == SPH_RANK_PROXIMITY \
|| ranker == SPH_RANK_MATCHANY \
|| ranker == SPH_RANK_FIELDMASK \
|| ranker == SPH_RANK_SPH04 \
|| ranker == SPH_RANK_EXPR }

@ranker = ranker
@rankexpr = rankexpr
end

# Set matches sorting mode.
Expand Down Expand Up @@ -567,7 +577,14 @@ def AddQuery(query, index = '*', comment = '')

# mode and limits
request = Request.new
request.put_int @offset, @limit, @mode, @ranker, @sort
request.put_int @offset, @limit, @mode, @ranker
# process the 'expr' ranker
if @ranker == SPH_RANK_EXPR
request.put_string @rankexpr
end

request.put_int @sort

request.put_string @sortby
# query itself
request.put_string query
Expand Down
2 changes: 1 addition & 1 deletion configure
Expand Up @@ -2340,7 +2340,7 @@ ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var.
ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.


am__api_version='1.11'
am__api_version='2.1.0'

# Find a good install program. We prefer a C program (faster),
# so one script is as good as another. But avoid the broken or
Expand Down
6 changes: 3 additions & 3 deletions doc/indexer.1
Expand Up @@ -2,12 +2,12 @@
.\" Title: indexer
.\" Author: [see the "Author" section]
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
.\" Date: 06/11/2011
.\" Date: 03/02/2012
.\" Manual: Sphinxsearch
.\" Source: 2.0.2
.\" Source: 2.1.0
.\" Language: English
.\"
.TH "INDEXER" "1" "06/11/2011" "2\&.0\&.2" "Sphinxsearch"
.TH "INDEXER" "1" "03/02/2012" "2\&.1\&.0" "Sphinxsearch"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions doc/indextool.1
Expand Up @@ -2,12 +2,12 @@
.\" Title: indextool
.\" Author: [see the "Author" section]
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
.\" Date: 06/11/2011
.\" Date: 03/02/2012
.\" Manual: Sphinxsearch
.\" Source: 2.0.2
.\" Source: 2.1.0
.\" Language: English
.\"
.TH "INDEXTOOL" "1" "06/11/2011" "2\&.0\&.2" "Sphinxsearch"
.TH "INDEXTOOL" "1" "03/02/2012" "2\&.1\&.0" "Sphinxsearch"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
Expand Down
10 changes: 5 additions & 5 deletions doc/manpages.xml
Expand Up @@ -12,7 +12,7 @@

<refmiscinfo class="manual">Sphinxsearch</refmiscinfo>

<refmiscinfo class="version">2.0.2</refmiscinfo>
<refmiscinfo class="version">2.1.0</refmiscinfo>
</refmeta>

<refnamediv>
Expand Down Expand Up @@ -467,7 +467,7 @@ $ indexer mysmallindex mybigindex</programlisting>

<refmiscinfo class="manual">Sphinxsearch</refmiscinfo>

<refmiscinfo class="version">2.0.2</refmiscinfo>
<refmiscinfo class="version">2.1.0</refmiscinfo>
</refmeta>

<refnamediv>
Expand Down Expand Up @@ -922,7 +922,7 @@ $ searchd --config /home/myuser/sphinx.conf --status</programlisting>

<refmiscinfo class="manual">Sphinxsearch</refmiscinfo>

<refmiscinfo class="version">2.0.2</refmiscinfo>
<refmiscinfo class="version">2.1.0</refmiscinfo>
</refmeta>

<refnamediv>
Expand Down Expand Up @@ -1311,7 +1311,7 @@ $ searchd --config /home/myuser/sphinx.conf --status</programlisting>

<refmiscinfo class="manual">Sphinxsearch</refmiscinfo>

<refmiscinfo class="version">2.0.2</refmiscinfo>
<refmiscinfo class="version">2.1.0</refmiscinfo>
</refmeta>

<refnamediv>
Expand Down Expand Up @@ -1430,7 +1430,7 @@ zoning &gt; zoning </programlisting></para>

<refmiscinfo class="manual">Sphinxsearch</refmiscinfo>

<refmiscinfo class="version">2.0.2</refmiscinfo>
<refmiscinfo class="version">2.1.0</refmiscinfo>
</refmeta>

<refnamediv>
Expand Down
6 changes: 3 additions & 3 deletions doc/search.1
Expand Up @@ -2,12 +2,12 @@
.\" Title: search
.\" Author: [see the "Author" section]
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
.\" Date: 06/11/2011
.\" Date: 03/02/2012
.\" Manual: Sphinxsearch
.\" Source: 2.0.2
.\" Source: 2.1.0
.\" Language: English
.\"
.TH "SEARCH" "1" "06/11/2011" "2\&.0\&.2" "Sphinxsearch"
.TH "SEARCH" "1" "03/02/2012" "2\&.1\&.0" "Sphinxsearch"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions doc/searchd.1
Expand Up @@ -2,12 +2,12 @@
.\" Title: searchd
.\" Author: [see the "Author" section]
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
.\" Date: 06/11/2011
.\" Date: 03/02/2012
.\" Manual: Sphinxsearch
.\" Source: 2.0.2
.\" Source: 2.1.0
.\" Language: English
.\"
.TH "SEARCHD" "1" "06/11/2011" "2\&.0\&.2" "Sphinxsearch"
.TH "SEARCHD" "1" "03/02/2012" "2\&.1\&.0" "Sphinxsearch"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions doc/spelldump.1
Expand Up @@ -2,12 +2,12 @@
.\" Title: spelldump
.\" Author: [see the "Author" section]
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
.\" Date: 06/11/2011
.\" Date: 03/02/2012
.\" Manual: Sphinxsearch
.\" Source: 2.0.2
.\" Source: 2.1.0
.\" Language: English
.\"
.TH "SPELLDUMP" "1" "06/11/2011" "2\&.0\&.2" "Sphinxsearch"
.TH "SPELLDUMP" "1" "03/02/2012" "2\&.1\&.0" "Sphinxsearch"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
Expand Down

0 comments on commit 82a5ca1

Please sign in to comment.