sphinx 0.9.9.2117

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. data/.gitignore +4 -0
  2. data/README.rdoc +243 -0
  3. data/Rakefile +45 -0
  4. data/VERSION.yml +5 -0
  5. data/init.rb +1 -0
  6. data/lib/sphinx/buffered_io.rb +26 -0
  7. data/lib/sphinx/client.rb +2426 -0
  8. data/lib/sphinx/constants.rb +179 -0
  9. data/lib/sphinx/indifferent_access.rb +152 -0
  10. data/lib/sphinx/request.rb +121 -0
  11. data/lib/sphinx/response.rb +71 -0
  12. data/lib/sphinx/server.rb +170 -0
  13. data/lib/sphinx/timeout.rb +31 -0
  14. data/lib/sphinx.rb +51 -0
  15. data/spec/client_response_spec.rb +170 -0
  16. data/spec/client_spec.rb +669 -0
  17. data/spec/client_validations_spec.rb +859 -0
  18. data/spec/fixtures/default_search.php +8 -0
  19. data/spec/fixtures/default_search_index.php +8 -0
  20. data/spec/fixtures/excerpt_custom.php +11 -0
  21. data/spec/fixtures/excerpt_default.php +8 -0
  22. data/spec/fixtures/excerpt_flags.php +12 -0
  23. data/spec/fixtures/field_weights.php +9 -0
  24. data/spec/fixtures/filter.php +9 -0
  25. data/spec/fixtures/filter_exclude.php +9 -0
  26. data/spec/fixtures/filter_float_range.php +9 -0
  27. data/spec/fixtures/filter_float_range_exclude.php +9 -0
  28. data/spec/fixtures/filter_range.php +9 -0
  29. data/spec/fixtures/filter_range_exclude.php +9 -0
  30. data/spec/fixtures/filter_range_int64.php +10 -0
  31. data/spec/fixtures/filter_ranges.php +10 -0
  32. data/spec/fixtures/filters.php +10 -0
  33. data/spec/fixtures/filters_different.php +13 -0
  34. data/spec/fixtures/geo_anchor.php +9 -0
  35. data/spec/fixtures/group_by_attr.php +9 -0
  36. data/spec/fixtures/group_by_attrpair.php +9 -0
  37. data/spec/fixtures/group_by_day.php +9 -0
  38. data/spec/fixtures/group_by_day_sort.php +9 -0
  39. data/spec/fixtures/group_by_month.php +9 -0
  40. data/spec/fixtures/group_by_week.php +9 -0
  41. data/spec/fixtures/group_by_year.php +9 -0
  42. data/spec/fixtures/group_distinct.php +10 -0
  43. data/spec/fixtures/id_range.php +9 -0
  44. data/spec/fixtures/id_range64.php +9 -0
  45. data/spec/fixtures/index_weights.php +9 -0
  46. data/spec/fixtures/keywords.php +8 -0
  47. data/spec/fixtures/limits.php +9 -0
  48. data/spec/fixtures/limits_cutoff.php +9 -0
  49. data/spec/fixtures/limits_max.php +9 -0
  50. data/spec/fixtures/limits_max_cutoff.php +9 -0
  51. data/spec/fixtures/match_all.php +9 -0
  52. data/spec/fixtures/match_any.php +9 -0
  53. data/spec/fixtures/match_boolean.php +9 -0
  54. data/spec/fixtures/match_extended.php +9 -0
  55. data/spec/fixtures/match_extended2.php +9 -0
  56. data/spec/fixtures/match_fullscan.php +9 -0
  57. data/spec/fixtures/match_phrase.php +9 -0
  58. data/spec/fixtures/max_query_time.php +9 -0
  59. data/spec/fixtures/miltiple_queries.php +12 -0
  60. data/spec/fixtures/ranking_bm25.php +9 -0
  61. data/spec/fixtures/ranking_fieldmask.php +9 -0
  62. data/spec/fixtures/ranking_matchany.php +9 -0
  63. data/spec/fixtures/ranking_none.php +9 -0
  64. data/spec/fixtures/ranking_proximity.php +9 -0
  65. data/spec/fixtures/ranking_proximity_bm25.php +9 -0
  66. data/spec/fixtures/ranking_wordcount.php +9 -0
  67. data/spec/fixtures/retries.php +9 -0
  68. data/spec/fixtures/retries_delay.php +9 -0
  69. data/spec/fixtures/select.php +9 -0
  70. data/spec/fixtures/set_override.php +11 -0
  71. data/spec/fixtures/sort_attr_asc.php +9 -0
  72. data/spec/fixtures/sort_attr_desc.php +9 -0
  73. data/spec/fixtures/sort_expr.php +9 -0
  74. data/spec/fixtures/sort_extended.php +9 -0
  75. data/spec/fixtures/sort_relevance.php +9 -0
  76. data/spec/fixtures/sort_time_segments.php +9 -0
  77. data/spec/fixtures/sphinxapi.php +1633 -0
  78. data/spec/fixtures/update_attributes.php +8 -0
  79. data/spec/fixtures/update_attributes_mva.php +8 -0
  80. data/spec/fixtures/weights.php +9 -0
  81. data/spec/spec_helper.rb +24 -0
  82. data/spec/sphinx/sphinx-id64.conf +67 -0
  83. data/spec/sphinx/sphinx.conf +67 -0
  84. data/spec/sphinx/sphinx_test.sql +88 -0
  85. data/sphinx.gemspec +127 -0
  86. metadata +142 -0
@@ -0,0 +1,8 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->Query('query');
7
+
8
+ ?>
@@ -0,0 +1,8 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->Query('query', 'index');
7
+
8
+ ?>
@@ -0,0 +1,11 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->BuildExcerpts(array('10', '20'), 'index', 'word1 word2', array('before_match' => 'before',
7
+ 'after_match' => 'after',
8
+ 'chunk_separator' => 'separator',
9
+ 'limit' => 10));
10
+
11
+ ?>
@@ -0,0 +1,8 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->BuildExcerpts(array('10', '20'), 'index', 'word1 word2');
7
+
8
+ ?>
@@ -0,0 +1,12 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->BuildExcerpts(array('10', '20'), 'index', 'word1 word2', array('exact_phrase' => true,
7
+ 'single_passage' => true,
8
+ 'use_boundaries' => true,
9
+ 'weight_order' => true,
10
+ 'query_mode' => true));
11
+
12
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetFieldWeights(array('field1' => 10, 'field2' => 20));
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetFilter('attr', array(10, 20, 30));
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetFilter('attr', array(10, 20, 30), true);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetFilterFloatRange('attr', 10.5, 20.3);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetFilterFloatRange('attr', 10.5, 20.3, true);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetFilterRange('attr', 10, 20);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetFilterRange('attr', 10, 20, true);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,10 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetFilterRange('attr1', -10, 20);
7
+ $cl->SetFilterRange('attr2', '-1099511627770', '1099511627780');
8
+ $cl->Query('query');
9
+
10
+ ?>
@@ -0,0 +1,10 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetFilterRange('attr2', 30, 40);
7
+ $cl->SetFilterRange('attr1', 10, 20);
8
+ $cl->Query('query');
9
+
10
+ ?>
@@ -0,0 +1,10 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetFilter('attr2', array(40, 50));
7
+ $cl->SetFilter('attr1', array(10, 20, 30));
8
+ $cl->Query('query');
9
+
10
+ ?>
@@ -0,0 +1,13 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetFilterRange('attr1', 10, 20, true);
7
+ $cl->SetFilter('attr3', array(30, 40, 50));
8
+ $cl->SetFilterRange('attr1', 60, 70);
9
+ $cl->SetFilter('attr2', array(80, 90, 100), true);
10
+ $cl->SetFilterFloatRange('attr1', 60.8, 70.5);
11
+ $cl->Query('query');
12
+
13
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetGeoAnchor('attrlat', 'attrlong', 20.3, 40.7);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetGroupBy('attr', SPH_GROUPBY_ATTR);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetGroupBy('attr', SPH_GROUPBY_ATTRPAIR);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetGroupBy('attr', SPH_GROUPBY_DAY);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetGroupBy('attr', SPH_GROUPBY_DAY, 'somesort');
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetGroupBy('attr', SPH_GROUPBY_MONTH);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetGroupBy('attr', SPH_GROUPBY_WEEK);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetGroupBy('attr', SPH_GROUPBY_YEAR);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,10 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetGroupBy('attr', SPH_GROUPBY_DAY);
7
+ $cl->SetGroupDistinct('attr');
8
+ $cl->Query('query');
9
+
10
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetIDRange(10, 20);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetIDRange(8589934591, 17179869183);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetIndexWeights(array('index1' => 10, 'index2' => 20));
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,8 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->BuildKeywords('test', 'index', true);
7
+
8
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetLimits(10, 20);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetLimits(10, 20, 30, 40);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetLimits(10, 20, 30);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetLimits(10, 20, 30, 40);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetMatchMode(SPH_MATCH_ALL);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetMatchMode(SPH_MATCH_ANY);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetMatchMode(SPH_MATCH_BOOLEAN);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetMatchMode(SPH_MATCH_EXTENDED);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetMatchMode(SPH_MATCH_EXTENDED2);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetMatchMode(SPH_MATCH_FULLSCAN);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetMatchMode(SPH_MATCH_PHRASE);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetMaxQueryTime(1000);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,12 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetRetries(10, 20);
7
+ $cl->AddQuery('test1');
8
+ $cl->SetGroupBy('attr', SPH_GROUPBY_DAY);
9
+ $cl->AddQuery('test2');
10
+ $cl->RunQueries();
11
+
12
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetRankingMode(SPH_RANK_BM25);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetRankingMode(SPH_RANK_FIELDMASK);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetRankingMode(SPH_RANK_MATCHANY);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetRankingMode(SPH_RANK_NONE);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetRankingMode(SPH_RANK_PROXIMITY);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetRankingMode(SPH_RANK_PROXIMITY_BM25);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetRankingMode(SPH_RANK_WORDCOUNT);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetRetries(10);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetRetries(10, 20);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetSelect('attr1, attr2');
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,11 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetOverride('attr1', SPH_ATTR_INTEGER, array(10 => 20));
7
+ $cl->SetOverride('attr2', SPH_ATTR_FLOAT, array(11 => 30.3));
8
+ $cl->SetOverride('attr3', SPH_ATTR_BIGINT, array(12 => '1099511627780'));
9
+ $cl->Query('query');
10
+
11
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetSortMode(SPH_SORT_ATTR_ASC, 'sortby');
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetSortMode(SPH_SORT_ATTR_DESC, 'sortby');
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetSortMode(SPH_SORT_EXPR, 'sortby');
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetSortMode(SPH_SORT_EXTENDED, 'sortby');
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetSortMode(SPH_SORT_RELEVANCE);
7
+ $cl->Query('query');
8
+
9
+ ?>
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ require ("sphinxapi.php");
4
+
5
+ $cl = new SphinxClient();
6
+ $cl->SetSortMode(SPH_SORT_TIME_SEGMENTS, 'sortby');
7
+ $cl->Query('query');
8
+
9
+ ?>