Full-text search, full-text search engine

Source: Internet
Author: User

Full-text search, full-text search engine

I recently used the full-text search function. Here I will give a brief introduction to this function.

What is full-text search? The effect is as follows:

 

Enter any Chinese character or phrase in the search box, and the system will automatically search for information containing this word or phrase in a specific database.

My implementation process is to make this function into a separate control, use to directly reference this control, then assign a value to the data source, and rewrite the data verification method.

The implementation code is as follows:

<Span style = "white-space: pre"> </span> protected override void AutoCompleteExtender_GetDataSource (string sPrefix, int iCount, object context, ref IEnumerable result) {if (GetDataSource! = Null) {var dataSource = GetDataSource (sPrefix, context); if (dataSource! = Null) {var typeName = ""; foreach (var data in dataSource) {typeName = data. getType (). assemblyQualifiedName; break;} result = new object [] {dataSource, typeName };}} protected override string SaveClientState () {string result = string. empty; if (this. selectedData! = Null) {result = JSONSerializerExecute. SerializeWithType (this. SelectedData);} return result;} protected override void LoadClientState (string clientState) {if (! String. isNullOrEmpty (clientState) {IList state = JSONSerializerExecute. deserialize <IList> (clientState); this. selectedData = state ;}/// <summary> /// return from the client, verify the input content /// </summary> /// <param name = "chkString"> use the information passed in by this parameter for data verification </param> /// <param name = "context"> context set by the user </param> [ScriptControlMethod] public virtual object [] CheckInput (string chkString, object context) {if (ValidateInput! = Null) {var data = ValidateInput (chkString, context); if (data. count> 0) {object [] result = new object [] {data, data [0]. getType (). assemblyQualifiedName}; return result ;}} return null ;}
Page javascript

// Call this operation after the backend verification is successful. If one result is returned, the SPAN is directly created and displayed. If multiple results are returned, the dialog box _ onValidateInvokeComplete is displayed: function (result) {this. _ setInvokingStatus (false); if (this. _ autoCompleteControl) {this. _ autoCompleteControl. set_isInvoking (false);} var obj = null; if (result & result. length = 2) {var data = result [0]; var dataType = result [1]; if (data. length> 1) // more than one {for (var I = 0; I <data. length; I ++) {data [I]. _ type = dataType ;} Var sFeature = "dialogWidth: 500px; dialogHeight: 300px; center: yes; help: no; resizable: yes; scroll: no; status: no"; data. nameTable = $ NT; data. keyName = this. get_dataKeyName (); data. displayPropName = this. get_dataDisplayPropName (); data. descriptionPropName = this. get_dataDescriptionPropName (); var resultStr = window. showModalDialog (this. get_selectObjectDialogUrl (), data, sFeature); obj = data [resultStr];} el Se {obj = data [0]; obj. _ type = dataType ;}} if (obj! = Null) {this. _ tmpText = ""; if (this. _ multiSelect = false) {this. set_selectedData (new Array ();} if (this. _ allowSelectDuplicateObj |! This. _ checkDataInList (obj) Array. add (this. get_selectedData (), obj); this. yydatachanged ();} this. setInputAreaText () ;}, loadClientState: function (value) {if (value & value! = "") {Var state = Sys. Serialization. JavaScriptSerializer. deserialize (value); if (state! = Null & state. length) {this. set_selectedData (state) ;}}, saveClientState: function () {var state = ""; var data = this. get_selectedData (); for (var I = 0; I <data. length; I ++) {data [I]. _ dataType = undefined;} if (data) {state = Sys. serialization. javaScriptSerializer. serialize (data);} return state;}, dataBind: function () {this. setInputAreaText () ;}, add_checkDataMask: function (handler) {this. get_events (). addHandler ("onCheckDataMask", handler) ;}, remove_checkDataMask: function (handler) {this. get_events (). removeHandler ("onCheckDataMask", handler );}}

Data Verification

protected IEnumerable CommonAutoCompleteWithSelectorControl1_GetDataSource(string chkstring, object context)        {            IEnumerable result = null;            if (chkstring.IsNotWhiteSpace())                result = OtherFieldData.SearchKeyPointInfoByCnName(chkstring);            return result;        }        protected IList CommonAutoCompleteWithSelectorControl1_ValidateInput(string chkstring, object context)        {            IList result = null;            if (chkstring.IsNotWhiteSpace())                result = OtherFieldData.SearchKeyPointInfoByCnName(chkstring);            return result;        }
The data display function is extracted as a public part and encapsulated to enable data source binding and data verification for control reuse.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.