Database and entity implementation of full-text search

Source: Internet
Author: User
Tags serialization

in everyday business scenarios, it is not always necessary for each type of data to need structured storage, in many cases, just to save a form of data to be able to, as for subsequent queries, in addition to the form of ID , more rely on full-text search to achieve.

At present, we have a lot of processes, the main mode of work is: Start, from the main data to get the corresponding data into the transaction data, through the process of processing each link, the process at the end of the transaction data is then written back to the master data. In this process, there is little opportunity to query transaction data except for the process (except for full-text search). Therefore, the significance of database design for large amount of transaction data in the process is not very big.

In addition to the primary key resource_id outside, the key is xml_content field, which takes XML The data type holds the contents of the business entity. The use of XML types instead of binary or pure string types preserves the possibility of creating indexes for the content in an XML field.

      It is not enough to have only a table structure. For ease of use, we designed data entities and data access adapters for this data structure ( ). In addition, we have defined a set of attribute format. xml serialization mechanism because of the use of dynamic compilation, so we simply do not use.

    We look at the definition of the base class for this data entity:

[Serializable] [Xmlrootmapping ("Genericformdata")] [Xelementserializable] [Ortablemapping ("WF. Generic_form_data ")][objectcompare (" id ")]public class Genericformdata:workflowobjectbase{[description (" number ") [ Xmlobjectmapping][orfieldmapping ("resource_id", PrimaryKey = True)]public override string ID {get; set;}  [description ("title")][xmlobjectmapping][orfieldmapping ("SUBJECT")][stringlengthvalidator (1, 255, MessageTemplate = "Please fill in the title, and the length must be less than 255 characters")]public override string Subject {get; set;}  private Iuser _creator = null; [subclassorfieldmapping ("ID", "creator_id", isnullable = False)] [ Subclassorfieldmapping ("DisplayName", "creator_name", isnullable = False)][subclasstype (typeof (Oguuser))]public Virtual Iuser Creator{get{return This._creator;} Set{this._creator = (iuser) ogubase.createwrapperobject (value);}}  [description ("Creation Time")][xmlobjectmapping][orfieldmapping ("Create_time")][sqlbehavior (BindingFlags = Clausebindingflags.all, defaultexpression = "getdate ()")]public virtual DateTime createtime {get; set;}  [description ("XML")][orfieldmapping ("Xml_content")]public virtual string Xmlcontent {get; set;}  [orfieldmapping ("Search_content")][description ("Search contents")]public virtual string Searchcontent {get; set;}}

It can be seen that it is not very different from the general data entity class, except that there are xmlrootmapping,xmlobjectmapping , and so on to help serialize the object into XML .

if we want to Genericformdata serialized to XML , you only need to call xmlhelper.serializeobjecttoxml (data) can be.

When we want to use it, we just need to write a genericformdata Derived data entities, and from genericformdataadapterbase<t, tcollection derived Adapter

SampleFormData because it is stored in field, without creating an index, we can think of as unstructured. In the example above, its child object collection subdata adapter beforeinnerupdate , afterinnerupdate or afterload to deal with sub-objects.

Sometimes, it is not necessary to load both the main object and the child object, for example, only the main object is used in the list, and the form often uses both the main object and the child object.

In this scenario, the child objects are often lazy-loaded.

    Finally, it is important to note that not all objects can follow the xml serialization mechanism to serialize, in particular the case of cross-referencing of objects, This generic data is not as easy to retrieve as structured data. To alleviate this shortcoming, we are in the genericformdata genericformrelativedata searchcontent search_content full-text search field.

The app can put the text data you want to check in the searchcontent property, and then query:





Database and entity implementation of full-text search

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.