Link Queries

You can use link queries to query for documents based on criteria in the document, and in a connected document. For example, you might want to connect documents written by a particular user with values in the user profile.

To use linked queries, you must configure a ReferenceMemoryMappedType field that occurs in the documents that you want to query, which contains values that occur in the document references for the connected documents. ReferenceMemoryMappedType fields provide a fast lookup between child documents and a parent document. For example, for a user profile, this might be a UserName field in the documents that specifies the user that wrote a document, and the value of that field is the document reference for the user profile.

Configure the IDOL Content component for Linked Queries

To use link queries, you must configure a ReferenceMemoryMappedType field. You then index the documents. You must either ensure that you index the parent documents first (in which the ReferenceMemoryMapped values occur in the document reference), or use the DREREGENERATE index action to fix the parent-child ordering.

To configure the IDOL Content component for linked queries

  1. Open the IDX file of the documents that you want to index.

  2. Find the field that you want to use to link documents. This field must contain a value that occurs in a normal field in the documents that you want to search, and in a reference field in the parent documents. For example, it might be a UserName field in the documents, and the value of this field is the document reference for the user profile.

  3. Open the IDOL Content component configuration file in a text editor.

  4. In the [FieldProcessing] section, go to the end of the list of field processing sections and add the next number. Set this parameter to the name of the field process that you want to create. For example:

    [FieldProcessing]
    ...
    10=SetNumericDateFields
    11=SetReferenceMemoryMappedFields
    
  5. Create a section for the field process. Create a property for the process (you define the property later by setting one or more applicable configuration parameters). Identify the fields that you want to associate with the process.

    NOTE:

    The properties that you create must not have the same name as the processes.

    For example:

    [SetReferenceMemoryMappedFields]
    Property=ReferenceMemoryMappedFields
    PropertyFieldCSVs=*/UserName,*/Author
  6. Create a section for the new property, in which you set the ReferenceMemoryMappedType property to True. For example:

    [ReferenceMemoryMappedFields]
    ReferenceMemoryMappedType=True
  7. Save and close the configuration file.

  8. Restart the IDOL Content component for your changes to take effect.

  9. Index the parent documents, and then index the rest of the documents. Alternatively, you can index all the documents and then send a DREREGENERATE index action to fix the parent-child relationships. For example:

    http://localhost:9001/DREREGENERATE?Type=ReferenceMemoryMapped

Send Linked Queries

Linked queries rely on the LINK field specifier, and the LinkFieldText action parameter. You can use these options in the QuerySuggest, SuggestOnText, and GetQueryTagValues actions.

To create a linked query, set the following parameters:

Text The query text that you want to find in the documents.
FieldText

A LINK field expression, setting the ReferenceMemoryMappedType field that connects the results documents to the parent documents that you want to link to. For example:

LINK{}:UserName

You can also add any other FieldText expressions that you want to use to restrict the results documents.

LinkFieldText

A FieldText expression that you want to apply in the parent documents (the documents in which the ReferenceMemoryMapped values occur in a ReferenceType field).

The LinkFieldText expression must be a simple FieldText expression, that is, it must use either all AND or all OR Boolean expressions. The fields that you use in the expressions must be MatchType, NumericDateType, NumericType, or ParametricType (when ParametricNumericMapping is enabled).

You cannot use metadata fields in the LinkFieldText expression, including the IDOL default metadata fields, and fields created by using the UserMetaFields parameter.

Example

A Users database has a set of user profile documents that use the user name as the document reference, and list interests and other user information. For example:

<DOCUMENT>
   <DREREFERENCE>User01</DREREFERENCE>
   <INTEREST>Soccer</INTEREST>
   <COUNTRY>USA</COUNTRY>
   <JOINED>01/01/2012</JOINED>
</DOCUMENT>
<DOCUMENT>
   <DREREFERENCE>User02</DREREFERENCE>
   <INTEREST>Food</INTEREST>
   <COUNTRY>UK</COUNTRY>
   <JOINED>02/06/2011</JOINED>
</DOCUMENT>

The same index has a SocialMedia database, which contains posts by these users. For example:

<DOCUMENT>
   <DREREFERENCE>SM0001</DREREFERENCE>
   <USERNAME>User01</USERNAME>
   <DRECONTENT>Just got my tickets for the final in Brazil!</DRECONTENT>
</DOCUMENT>
<DOCUMENT>
   <DREREFERENCE>SM0002</DREREFERENCE>
   <USERNAME>User02</USERNAME>
   <DRECONTENT>Brazil nuts are so moreish...</DRECONTENT>
</DOCUMENT>

The following standard query returns both of these documents:

action=Query&Text=Brazil

You can use a linked query to specify additional restrictions. The following query finds posts about Brazil by users who are interested in soccer:

action=Query&Text=Brazil&FieldText=LINK{}:USERNAME&LinkFieldText=MATCH{Soccer}:INTEREST

This returns the document SM0001, but not the document SM0002.

This query requires the following field configuration:


_HP_HTML5_bannerTitle.htm