当前位置: 首页>>代码示例>>PHP>>正文


PHP Apache_Solr_Document::getBoost方法代码示例

本文整理汇总了PHP中Apache_Solr_Document::getBoost方法的典型用法代码示例。如果您正苦于以下问题:PHP Apache_Solr_Document::getBoost方法的具体用法?PHP Apache_Solr_Document::getBoost怎么用?PHP Apache_Solr_Document::getBoost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Apache_Solr_Document的用法示例。


在下文中一共展示了Apache_Solr_Document::getBoost方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testClearReturnsDocumentToDefaultState

 public function testClearReturnsDocumentToDefaultState()
 {
     // set the document boost
     $this->_fixture->setBoost(0.5);
     // set a field
     $this->_fixture->someField = "some value";
     // clear the document to remove boost and fields
     $this->_fixture->clear();
     // document boost should now be false
     $this->assertFalse($this->_fixture->getBoost());
     // document fields should now be empty
     $this->assertEquals(0, count($this->_fixture->getFieldNames()));
     $this->assertEquals(0, count($this->_fixture->getFieldValues()));
     $this->assertEquals(0, count($this->_fixture->getFieldBoosts()));
     // document iterator should now be empty
     $this->assertEquals(0, iterator_count($this->_fixture));
 }
开发者ID:rande,项目名称:sfSolrPlugin,代码行数:17,代码来源:DocumentTest.php

示例2: _documentToXmlFragment

 /**
  * Create an XML fragment from a {@link Apache_Solr_Document} instance appropriate for use inside a Solr add call
  *
  * @return string
  */
 protected function _documentToXmlFragment(Apache_Solr_Document $document)
 {
     $xml = '<doc';
     if ($document->getBoost() !== false) {
         $xml .= ' boost="' . $document->getBoost() . '"';
     }
     $xml .= '>';
     foreach ($document as $key => $value) {
         $key = htmlspecialchars($key, ENT_QUOTES, 'UTF-8');
         $fieldBoost = $document->getFieldBoost($key);
         if (is_array($value)) {
             foreach ($value as $multivalue) {
                 $xml .= '<field name="' . $key . '"';
                 if ($fieldBoost !== false) {
                     $xml .= ' boost="' . $fieldBoost . '"';
                     // only set the boost for the first field in the set
                     $fieldBoost = false;
                 }
                 $multivalue = htmlspecialchars($multivalue, ENT_NOQUOTES, 'UTF-8');
                 $xml .= '>' . $multivalue . '</field>';
             }
         } else {
             $xml .= '<field name="' . $key . '"';
             if ($fieldBoost !== false) {
                 $xml .= ' boost="' . $fieldBoost . '"';
             }
             $value = htmlspecialchars($value, ENT_NOQUOTES, 'UTF-8');
             $xml .= '>' . $value . '</field>';
         }
     }
     $xml .= '</doc>';
     // replace any control characters to avoid Solr XML parser exception
     return $this->_stripCtrlChars($xml);
 }
开发者ID:austinvernsonger,项目名称:casebox,代码行数:39,代码来源:Service.php

示例3: _documentToXmlFragment

 /**
  * Create an XML fragment from a {@link Apache_Solr_Document} instance appropriate for use inside a Solr add call
  *
  * @return string
  */
 protected function _documentToXmlFragment(Apache_Solr_Document $document)
 {
     $xml = '<doc';
     if ($document->getBoost() !== false) {
         $xml .= ' boost="' . $document->getBoost() . '"';
     }
     $xml .= '>';
     foreach ($document as $key => $value) {
         $key = htmlspecialchars($key, ENT_QUOTES, 'UTF-8');
         $fieldBoost = $document->getFieldBoost($key);
         if ($key) {
             if (is_array($value)) {
                 foreach ($value as $multivalue) {
                     $xml .= '<field name="' . $key . '"';
                     if ($fieldBoost !== false) {
                         $xml .= ' boost="' . $fieldBoost . '"';
                         // only set the boost for the first field in the set
                         $fieldBoost = false;
                     }
                     if (!mb_check_encoding($multivalue, 'UTF-8')) {
                         $multivalue = utf8_encode($multivalue);
                     }
                     $multivalue = htmlspecialchars($multivalue, ENT_NOQUOTES, 'UTF-8');
                     $xml .= '>' . $multivalue . '</field>';
                 }
             } else {
                 $xml .= '<field name="' . $key . '"';
                 if ($fieldBoost !== false) {
                     $xml .= ' boost="' . $fieldBoost . '"';
                 }
                 if (!mb_check_encoding($value, 'UTF-8')) {
                     $value = utf8_encode($value);
                 }
                 $value = htmlspecialchars($value, ENT_NOQUOTES, 'UTF-8');
                 $xml .= '>' . $value . '</field>';
             }
         }
     }
     $xml .= '</doc>';
     return $xml;
 }
开发者ID:hfroese,项目名称:mediawiki-extensions-BlueSpiceExtensions,代码行数:46,代码来源:Service.php


注:本文中的Apache_Solr_Document::getBoost方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。