A CmdSearch command using a Catalog

Introduced properties

init defaultinit(model: Model, catalog: Catalog, filter: nullable ModelFilter, query: nullable String, limit: nullable Int, page: nullable Int, count: nullable Int, max: nullable Int)

nitc :: CmdCatalogSearch :: defaultinit

private fun name_sorter=(name_sorter: NameComparator)

nitc :: CmdCatalogSearch :: name_sorter=

private fun score_sorter=(score_sorter: ScoreComparator)

nitc :: CmdCatalogSearch :: score_sorter=

Redefined properties

redef type SELF: CmdCatalogSearch

nitc $ CmdCatalogSearch :: SELF

Type of this instance, automatically specialized in every class
redef fun init_results: CmdMessage

nitc $ CmdCatalogSearch :: init_results

Initialize the results list

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type ITEM: Object

nitc :: CmdList :: ITEM

Type of result
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
private var _catalog: Catalog

nitc :: CmdCatalog :: _catalog

Catalog to query at
private var _count: nullable Int

nitc :: CmdList :: _count

Total number of ret
private var _filter: nullable ModelFilter

nitc :: DocCommand :: _filter

ModelFilter to apply if any
private var _limit: nullable Int

nitc :: CmdList :: _limit

Limit the items in the list
private var _max: nullable Int

nitc :: CmdList :: _max

Total number of pages
private var _model: Model

nitc :: DocCommand :: _model

Model to retrieve data for
private var _page: nullable Int

nitc :: CmdList :: _page

Page to display
private var _query: nullable String

nitc :: CmdSearch :: _query

Free text command string
private var _results: nullable Array[ITEM]

nitc :: CmdList :: _results

Items in the list
private var _sorter: nullable Comparator

nitc :: CmdEntities :: _sorter

private var _sorter: nullable Comparator

nitc :: CmdList :: _sorter

Comparator used to sort the list
fun catalog: Catalog

nitc :: CmdCatalog :: catalog

Catalog to query at
protected fun catalog=(catalog: Catalog)

nitc :: CmdCatalog :: catalog=

Catalog to query at
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
fun cmd_filter: ModelFilter

nitc :: DocCommand :: cmd_filter

Return a new filter for that command execution.
fun count: nullable Int

nitc :: CmdList :: count

Total number of ret
fun count=(count: nullable Int)

nitc :: CmdList :: count=

Total number of ret
init defaultinit(model: Model, filter: nullable ModelFilter, limit: nullable Int, page: nullable Int, count: nullable Int, max: nullable Int)

nitc :: CmdList :: defaultinit

init defaultinit(model: Model, catalog: Catalog, filter: nullable ModelFilter)

nitc :: CmdCatalog :: defaultinit

init defaultinit(model: Model, filter: nullable ModelFilter, limit: nullable Int, page: nullable Int, count: nullable Int, max: nullable Int)

nitc :: CmdEntities :: defaultinit

init defaultinit(model: Model, catalog: Catalog, filter: nullable ModelFilter, query: nullable String, limit: nullable Int, page: nullable Int, count: nullable Int, max: nullable Int)

nitc :: CmdCatalogSearch :: defaultinit

init defaultinit(model: Model, filter: nullable ModelFilter, limit: nullable Int, page: nullable Int, count: nullable Int, max: nullable Int, query: nullable String)

nitc :: CmdSearch :: defaultinit

init defaultinit(model: Model, filter: nullable ModelFilter)

nitc :: DocCommand :: defaultinit

abstract fun execute(no_color: nullable Bool)

nitc :: DocCommand :: execute

fun filter: nullable ModelFilter

nitc :: DocCommand :: filter

ModelFilter to apply if any
protected fun filter=(filter: nullable ModelFilter)

nitc :: DocCommand :: filter=

ModelFilter to apply if any
fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun hash: Int

core :: Object :: hash

The hash code of the object.
fun http_init(req: HttpRequest): CmdMessage

nitc :: DocCommand :: http_init

Init the command from an HTTPRequest
init init

core :: Object :: init

fun init_command: CmdMessage

nitc :: DocCommand :: init_command

Initialize the command
fun init_results: CmdMessage

nitc :: CmdList :: init_results

Initialize the results list
fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
fun limit: nullable Int

nitc :: CmdList :: limit

Limit the items in the list
fun limit=(limit: nullable Int)

nitc :: CmdList :: limit=

Limit the items in the list
fun max: nullable Int

nitc :: CmdList :: max

Total number of pages
fun max=(max: nullable Int)

nitc :: CmdList :: max=

Total number of pages
fun model: Model

nitc :: DocCommand :: model

Model to retrieve data for
protected fun model=(model: Model)

nitc :: DocCommand :: model=

Model to retrieve data for
private fun name_sorter=(name_sorter: NameComparator)

nitc :: CmdCatalogSearch :: name_sorter=

private intern fun native_class_name: CString

core :: Object :: native_class_name

The class name of the object in CString format.
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun page: nullable Int

nitc :: CmdList :: page

Page to display
fun page=(page: nullable Int)

nitc :: CmdList :: page=

Page to display
fun paginate

nitc :: CmdList :: paginate

Paginate the results
fun parser_init(arg: String, options: CmdOptions): CmdMessage

nitc :: DocCommand :: parser_init

Initialize the command from the CommandParser data
fun print_list(list_title: nullable String, list_items: nullable Array[MEntity], no_color: nullable Bool)

nitc :: CmdList :: print_list

fun query: nullable String

nitc :: CmdSearch :: query

Free text command string
fun query=(query: nullable String)

nitc :: CmdSearch :: query=

Free text command string
fun results: nullable Array[ITEM]

nitc :: CmdList :: results

Items in the list
fun results=(results: nullable Array[ITEM])

nitc :: CmdList :: results=

Items in the list
private fun score_sorter=(score_sorter: ScoreComparator)

nitc :: CmdCatalogSearch :: score_sorter=

fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
fun sort

nitc :: CmdList :: sort

Sort mentities with sorter
fun sorter: nullable Comparator

nitc :: CmdList :: sorter

Comparator used to sort the list
fun sorter=(sorter: nullable Comparator)

nitc :: CmdList :: sorter=

Comparator used to sort the list
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
fun to_html: Writable

nitc :: DocCommand :: to_html

Render results as a HTML string
abstract fun to_json: nullable Serializable

nitc :: DocCommand :: to_json

Return a JSON Serializable representation of self results
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_md: Writable

nitc :: DocCommand :: to_md

Render results as a Markdown string
fun to_s: String

core :: Object :: to_s

User readable representation of self.
package_diagram nitc::CmdCatalogSearch CmdCatalogSearch nitc::CmdCatalog CmdCatalog nitc::CmdCatalogSearch->nitc::CmdCatalog nitc::CmdSearch CmdSearch nitc::CmdCatalogSearch->nitc::CmdSearch nitc::DocCommand DocCommand nitc::CmdCatalog->nitc::DocCommand nitc::CmdEntities CmdEntities nitc::CmdSearch->nitc::CmdEntities ...nitc::DocCommand ... ...nitc::DocCommand->nitc::DocCommand ...nitc::CmdEntities ... ...nitc::CmdEntities->nitc::CmdEntities

Ancestors

abstract class CmdEntities

nitc :: CmdEntities

A list of mentities
abstract class CmdList

nitc :: CmdList

A command that returns a list of results
abstract class DocCommand

nitc :: DocCommand

Documentation command
interface Object

core :: Object

The root of the class hierarchy.

Parents

abstract class CmdCatalog

nitc :: CmdCatalog

A DocCommand based on a Catalog
class CmdSearch

nitc :: CmdSearch

A free text search command

Class definitions

nitc $ CmdCatalogSearch
# A CmdSearch command using a Catalog
class CmdCatalogSearch
	super CmdCatalog
	super CmdSearch

	autoinit(model, catalog, filter, query, limit, page, count, max)

	redef fun init_results do
		if results != null then return new CmdSuccess

		var res = super
		if not res isa CmdSuccess then return res

		var query = self.query
		if query == null then return new ErrorNoQuery
		sorter = null

		var filter = self.filter
		var index = model.index

		# lookup by name prefix
		var matches = index.find_by_name_prefix(query, filter).uniq.
			sort(lname_sorter, name_sorter, kind_sorter)
		matches = matches.rerank.sort(vis_sorter, score_sorter)

		# lookup by tags
		var malus = matches.length
		if catalog.tag2proj.has_key(query) then
			for mpackage in catalog.tag2proj[query] do
				if filter != null and not filter.accept_mentity(mpackage) then continue
				matches.add new IndexMatch(mpackage, malus)
				malus += 1
			end
			matches = matches.uniq.rerank.sort(vis_sorter, score_sorter)
		end

		# lookup by full_name prefix
		malus = matches.length
		var full_matches = new IndexMatches
		for match in index.find_by_full_name_prefix(query, filter).
			sort(lfname_sorter, fname_sorter) do
			match.score += 1
			full_matches.add match
		end
		matches = matches.uniq

		# lookup by similarity
		malus = matches.length
		var sim_matches = new IndexMatches
		for match in index.find_by_similarity(query, filter).sort(score_sorter, kind_sorter, lname_sorter, name_sorter) do
			if match.score > query.length then break
			match.score += 1
			sim_matches.add match
		end
		matches.add_all sim_matches
		matches = matches.uniq
		results = matches.rerank.sort(vis_sorter, score_sorter).mentities
		return res
	end

	private var score_sorter = new ScoreComparator
	private var vis_sorter = new VisibilityComparator
	private var name_sorter = new NameComparator
	private var lname_sorter = new NameLengthComparator
	private var fname_sorter = new FullNameComparator
	private var lfname_sorter = new FullNameLengthComparator
	private var kind_sorter = new MEntityComparator
end
src/doc/commands/commands_catalog.nit:31,1--98,3