ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilRepositoryObjectDetailSearch Class Reference
+ Collaboration diagram for ilRepositoryObjectDetailSearch:

Public Member Functions

 __construct ($a_obj_id)
 constructor More...
 
 getSettings ()
 Get settings. More...
 
 getObjId ()
 get obj id More...
 
 getType ()
 
 setQueryString ($a_query)
 
 getQueryString ()
 get query string More...
 
 performSearch ()
 Perform search. More...
 

Protected Member Functions

 performLuceneSearch ()
 Perform lucene search. More...
 
 performDBSearch ()
 Perform DB search. More...
 

Protected Attributes

 $settings = null
 
 $obj_id
 
 $type
 
 $query_string
 

Detailed Description

Definition at line 17 of file class.ilRepositoryObjectDetailSearch.php.

Constructor & Destructor Documentation

◆ __construct()

ilRepositoryObjectDetailSearch::__construct (   $a_obj_id)

constructor

Definition at line 28 of file class.ilRepositoryObjectDetailSearch.php.

References ilObject\_lookupType(), ilSearchSettings\getInstance(), getObjId(), and settings().

29  {
30  $this->obj_id = $a_obj_id;
31  $this->type = ilObject::_lookupType($this->getObjId());
32 
34  }
settings()
Definition: settings.php:2
static _lookupType($a_id, $a_reference=false)
lookup object type
+ Here is the call graph for this function:

Member Function Documentation

◆ getObjId()

ilRepositoryObjectDetailSearch::getObjId ( )

get obj id

Returns
type

Definition at line 49 of file class.ilRepositoryObjectDetailSearch.php.

References $obj_id.

Referenced by __construct(), performDBSearch(), and performLuceneSearch().

+ Here is the caller graph for this function:

◆ getQueryString()

ilRepositoryObjectDetailSearch::getQueryString ( )

get query string

Definition at line 69 of file class.ilRepositoryObjectDetailSearch.php.

References $query_string.

Referenced by performDBSearch(), and performLuceneSearch().

+ Here is the caller graph for this function:

◆ getSettings()

ilRepositoryObjectDetailSearch::getSettings ( )

Get settings.

Returns
ilSearchSettings

Definition at line 40 of file class.ilRepositoryObjectDetailSearch.php.

References $settings.

Referenced by performDBSearch(), and performSearch().

+ Here is the caller graph for this function:

◆ getType()

ilRepositoryObjectDetailSearch::getType ( )

Definition at line 54 of file class.ilRepositoryObjectDetailSearch.php.

References $type.

Referenced by performDBSearch().

+ Here is the caller graph for this function:

◆ performDBSearch()

ilRepositoryObjectDetailSearch::performDBSearch ( )
protected

Perform DB search.

Returns
ilRepositoryObjectDetailSearchResult

Definition at line 131 of file class.ilRepositoryObjectDetailSearch.php.

References ilObjectSearchFactory\getByTypeSearchInstance(), getObjId(), getQueryString(), getSettings(), getType(), ilSearchSettings\OPERATOR_AND, QP_COMBINATION_AND, and QP_COMBINATION_OR.

Referenced by performSearch().

132  {
133  // query parser
134  include_once 'Services/Search/classes/class.ilQueryParser.php';
135 
136  $query_parser = new ilQueryParser($this->getQueryString());
137 
138  $query_parser->setCombination(
139  ($this->getSettings()->getDefaultOperator() == ilSearchSettings::OPERATOR_AND) ?
142  );
143  $query_parser->parse();
144 
145  if (!$query_parser->validate()) {
146  throw new Exception($query_parser->getMessage());
147  }
148  include_once 'Services/Search/classes/class.ilSearchResult.php';
149  $search_result = new ilSearchResult();
150 
151  include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
152  $search = ilObjectSearchFactory::getByTypeSearchInstance($this->getType(), $query_parser);
153 
154  switch ($this->getType()) {
155  case 'wiki':
156  $search->setFilter(array('wpg'));
157  break;
158  }
159 
160  $search->setIdFilter(array($this->getObjId()));
161 
162  $search_result->mergeEntries($search->performSearch());
163 
164  include_once './Services/Search/classes/class.ilRepositoryObjectDetailSearchResult.php';
165  $detail_search_result = new ilRepositoryObjectDetailSearchResult();
166 
167  foreach ($search_result->getEntries() as $entry) {
168  foreach ((array) $entry['child'] as $child) {
169  $detail_search_result->addResultSet(
170  array(
171  'obj_id' => $entry['obj_id'],
172  'item_id' => $child
173  )
174  );
175  }
176  }
177  return $detail_search_result;
178  }
const QP_COMBINATION_OR
static getByTypeSearchInstance($a_object_type, $a_query_parser)
const QP_COMBINATION_AND
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ performLuceneSearch()

ilRepositoryObjectDetailSearch::performLuceneSearch ( )
protected

Perform lucene search.

Exceptions
ilLuceneQueryParserException

Definition at line 93 of file class.ilRepositoryObjectDetailSearch.php.

References ilLuceneSearcher\getInstance(), ilLoggerFactory\getLogger(), getObjId(), and getQueryString().

Referenced by performSearch().

94  {
95  include_once './Services/Search/classes/Lucene/class.ilLuceneQueryParser.php';
96  try {
97  $qp = new ilLuceneQueryParser($this->getQueryString());
98  $qp->parse();
99  } catch (ilLuceneQueryParserException $e) {
100  ilLoggerFactory::getLogger('src')->warning('Invalid query: ' . $e->getMessage());
101  throw $e;
102  }
103 
104  include_once './Services/Search/classes/Lucene/class.ilLuceneSearcher.php';
105  $searcher = ilLuceneSearcher::getInstance($qp);
106  $searcher->highlight(array($this->getObjId()));
107 
108  include_once './Services/Search/classes/class.ilRepositoryObjectDetailSearchResult.php';
109  $detail_search_result = new ilRepositoryObjectDetailSearchResult();
110 
111  if ($searcher->getHighlighter() instanceof ilLuceneHighlighterResultParser) {
112  foreach ($searcher->getHighlighter()->getSubItemIds($this->getObjId()) as $sub_id) {
113  $detail_search_result->addResultSet(
114  array(
115  'obj_id' => $this->getObjId(),
116  'item_id' => $sub_id,
117  'relevance' => $searcher->getHighlighter()->getRelevance($this->getObjId(), $sub_id),
118  'content' => $searcher->getHighlighter()->getContent($this->getObjId(), $sub_id)
119  )
120  );
121  }
122  }
123  return $detail_search_result;
124  }
Parses result XML from lucene search highlight.
static getInstance(ilLuceneQueryParser $qp)
Get singleton instance.
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ performSearch()

ilRepositoryObjectDetailSearch::performSearch ( )

Perform search.

Returns
ilRepositoryObjectDetailSearchResult
Exceptions
ilLuceneQueryParserException

Definition at line 80 of file class.ilRepositoryObjectDetailSearch.php.

References getSettings(), performDBSearch(), and performLuceneSearch().

81  {
82  if ($this->getSettings()->enabledLucene()) {
83  return $this->performLuceneSearch();
84  } else {
85  return $this->performDBSearch();
86  }
87  }
+ Here is the call graph for this function:

◆ setQueryString()

ilRepositoryObjectDetailSearch::setQueryString (   $a_query)

Definition at line 60 of file class.ilRepositoryObjectDetailSearch.php.

61  {
62  $this->query_string = $a_query;
63  }

Field Documentation

◆ $obj_id

ilRepositoryObjectDetailSearch::$obj_id
protected

Definition at line 21 of file class.ilRepositoryObjectDetailSearch.php.

Referenced by getObjId().

◆ $query_string

ilRepositoryObjectDetailSearch::$query_string
protected

Definition at line 23 of file class.ilRepositoryObjectDetailSearch.php.

Referenced by getQueryString().

◆ $settings

ilRepositoryObjectDetailSearch::$settings = null
protected

Definition at line 19 of file class.ilRepositoryObjectDetailSearch.php.

Referenced by getSettings().

◆ $type

ilRepositoryObjectDetailSearch::$type
protected

Definition at line 22 of file class.ilRepositoryObjectDetailSearch.php.

Referenced by getType().


The documentation for this class was generated from the following file: