{"__v":3,"_id":"576470a22ccec80e00dc93d7","category":{"__v":2,"_id":"56be3389be55991700c3ca11","pages":["56be338abe55991700c3ca13","56be34fa37d84017009de5f7"],"project":"56be3387be55991700c3ca0d","version":"56be3388be55991700c3ca10","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-02-12T19:33:29.389Z","from_sync":false,"order":2,"slug":"documentation","title":"Documentation"},"parentDoc":null,"project":"56be3387be55991700c3ca0d","user":"5633ec9b35355017003ca3f2","version":{"__v":8,"_id":"56be3388be55991700c3ca10","project":"56be3387be55991700c3ca0d","createdAt":"2016-02-12T19:33:28.313Z","releaseDate":"2016-02-12T19:33:28.313Z","categories":["56be3389be55991700c3ca11","57646709b0a8be1900fcd0d8","5764671c89da831700590782","57646d30c176520e00ea8fe5","5764715d4f867c0e002bc8e3","57698fa2e93bfd190028815c","576c2af16c24681700c902da","5787da96b008c91900aae865"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-06-17T21:50:26.908Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Quickstart\"\n}\n[/block]\nIf you're already familiar with the basics and just looking for some sample code, here you go!\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"rsolr = RSolr.connect :url => 'http://index.websolr.com/solr/0a1b2c3d4e5f'\\nrsolr.get 'terms', :params => { 'terms.fl' => '', 'terms.prefix' => '' }\\n# ...\",\n      \"language\": \"ruby\"\n    }\n  ]\n}\n[/block]\n## Installing and using RSolr\n\nPlease refer to our article on [RSolr](doc:rsolr) for a more comprehensive look at general RSolr usage.\n\n## TermsComponent basics\n\n`TermsComponent` bases its responses on the contents of a field which you specify. This can be a specific field, \n\nIf you use dynamic field naming conventions you could also copy all of your text fields into a single text field.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"  <?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n  <schema>\\n    <types>\\n      \\n      <fieldType name=\\\"text\\\" class=\\\"solr.TextField\\\">\\n        <!-- the rest of your definition for a typical text field goes here -->\\n      </fieldType>\\n      \\n      <!-- other field types omitted for brevity -->\\n      \\n    </types>\\n    <fields>\\n      \\n      <!-- other fields omitted for brevity -->\\n      \\n      <field name=\\\"*_text\\\" type=\\\"text\\\" indexed=\\\"true\\\" stored=\\\"false\\\" multiValued=\\\"true\\\" />\\n      <field name=\\\"allText\\\" type=\\\"text\\\" indexed=\\\"true\\\" stored=\\\"false\\\" multiValued=\\\"true\\\" />\\n      \\n    </fields>\\n    \\n    <!--\\n      Copy each of the text fields into allText for use by TermsComponent,\\n      SpellcheckComponent, and others.\\n    -->\\n    <copyField source=\\\"*_text\\\" dest=\\\"allText\\\"/>\\n    \\n  </schema>\",\n      \"language\": \"xml\"\n    }\n  ]\n}\n[/block]\n## Interacting with TermsComponent\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"rsolr = RSolr.connect :url => 'http://index.websolr.com/solr/0a1b2c3d4e5f'\\nrsolr.get 'terms', :params => { 'terms.fl' => '', 'terms.prefix' => '' }\",\n      \"language\": \"ruby\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"search-autocomplete-with-solr-termscomponent-and-rsolr","type":"basic","title":"Search Autocomplete with Solr TermsComponent and RSolr"}

Search Autocomplete with Solr TermsComponent and RSolr


[block:api-header] { "type": "basic", "title": "Quickstart" } [/block] If you're already familiar with the basics and just looking for some sample code, here you go! [block:code] { "codes": [ { "code": "rsolr = RSolr.connect :url => 'http://index.websolr.com/solr/0a1b2c3d4e5f'\nrsolr.get 'terms', :params => { 'terms.fl' => '', 'terms.prefix' => '' }\n# ...", "language": "ruby" } ] } [/block] ## Installing and using RSolr Please refer to our article on [RSolr](doc:rsolr) for a more comprehensive look at general RSolr usage. ## TermsComponent basics `TermsComponent` bases its responses on the contents of a field which you specify. This can be a specific field, If you use dynamic field naming conventions you could also copy all of your text fields into a single text field. [block:code] { "codes": [ { "code": " <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <schema>\n <types>\n \n <fieldType name=\"text\" class=\"solr.TextField\">\n <!-- the rest of your definition for a typical text field goes here -->\n </fieldType>\n \n <!-- other field types omitted for brevity -->\n \n </types>\n <fields>\n \n <!-- other fields omitted for brevity -->\n \n <field name=\"*_text\" type=\"text\" indexed=\"true\" stored=\"false\" multiValued=\"true\" />\n <field name=\"allText\" type=\"text\" indexed=\"true\" stored=\"false\" multiValued=\"true\" />\n \n </fields>\n \n <!--\n Copy each of the text fields into allText for use by TermsComponent,\n SpellcheckComponent, and others.\n -->\n <copyField source=\"*_text\" dest=\"allText\"/>\n \n </schema>", "language": "xml" } ] } [/block] ## Interacting with TermsComponent [block:code] { "codes": [ { "code": "rsolr = RSolr.connect :url => 'http://index.websolr.com/solr/0a1b2c3d4e5f'\nrsolr.get 'terms', :params => { 'terms.fl' => '', 'terms.prefix' => '' }", "language": "ruby" } ] } [/block]