Text highlighting

FlexSearch supports text highlighting across all query types provided correct highlighting options are set in the request query. Text highlighting is supported only for Text field types.

PreTag and PostTag can be specified and the returned result will contain the matched text between pre and post tags. This is helpful in case the results are to be expressed in a web page.

POST http://localhost:9800/indices/country/search HTTP/1.1
{"queryName":"","columns":["country","background"],"count":10,"highlights":{"fragmentsToReturn":2,"highlightedFields":["background"],"postTag":"</B>","preTag":"<B>"},"indexName":"country","orderBy":"score","orderByDirection":0,"cutOff":0,"distinctBy":"","skip":0,"queryString":"anyOf(background, 'most prosperous countries')","returnScore":true,"preSearchScript":"","overridePredefinedQueryOptions":false,"returnEmptyStringForNull":true,"variables":{}}

Response

HTTP/1.1 200
Content-Type : application/json
Content-Length : 12412
{"data":{"documents":[{"fields":{"background":"Singapore was founded as a British trading colony in 1819. It joined the Malaysian Federation in 1963 but separated two years later and became independent. Singapore subsequently became one of the world's most prosperous countries with strong international trading links (its port is one of the world's busiest in terms of tonnage handled) and with per capita GDP equal to that of the leading nations of Western Europe."},"id":"210","indexName":"country","timeStamp":20161019202028170,"modifyIndex":210,"highlights":[" of the world's <B>most</B> <B>prosperous</B> <B>countries</B> with strong international trading links (its port is one"],"score":0.7496964931488037},{"fields":{"background":"First colonized by the Spanish the islands came under British control in the early 19th century. The islands' sugar industry was hurt by the emancipation of the slaves in 1834. Manpower was replaced with the importation of contract laborers from India between 1845 and 1917 which boosted sugar production as well as the cocoa industry. The discovery of oil on Trinidad in 1910 added another important export. Independence was attained in 1962. The country is one of the most prosperous in the Caribbean thanks largely to petroleum and natural gas production and processing. Tourism mostly in Tobago is targeted for expansion and is growing. The government is coping with a rise in violent crime."},"id":"236","indexName":"country","timeStamp":20161019202028220,"modifyIndex":236,"highlights":[" important export. Independence was attained in 1962. The country is one of the <B>most</B> <B>prosperous</B>"],"score":0.3187594413757324},{"fields":{"background":"Until recently only two autocratic presidents had ruled Gabon since its independence from France in 1960. The recent president of Gabon El Hadj Omar BONGO Ondimba -one of the longest-serving heads of state in the world - had dominated the country's political scene for four decades. President BONGO introduced a nominal multiparty system and a new constitution in the early 1990s. However allegations of electoral fraud during local elections in 2002-03 and the presidential elections in 2005 exposed the weaknesses of formal political structures in Gabon. President BONGO died in June 2009 and was replaced in accordance with the constitution by Rose Francine ROGOMBE the president of the Senate. New elections are planned for the summer of 2009. This will be the first Gabonese elections in which BONGO is not participating. Despite political conditions a small population abundant natural resources and considerable foreign support have helped make Gabon one of the more prosperous and stable African countries."},"id":"87","indexName":"country","timeStamp":20161019202027856,"modifyIndex":87,"highlights":[" resources and considerable foreign support have helped make Gabon one of the more <B>prosperous</B> and stable"," African <B>countries</B>."],"score":0.2996866703033447},{"fields":{"background":"Lithuanian lands were united under MINDAUGAS in 1236; over the next century through alliances and conquest Lithuania extended its territory to include most of present-day Belarus and Ukraine. By the end of the 14th century Lithuania was the largest state in Europe. An alliance with Poland in 1386 led the two countries into a union through the person of a common ruler. In 1569 Lithuania and Poland formally united into a single dual state the Polish-Lithuanian Commonwealth. This entity survived until 1795 when its remnants were partitioned by surrounding countries. Lithuania regained its independence following World War I but was annexed by the USSR in 1940 - an action never recognized by the US and many other countries. On 11 March 1990 Lithuania became the first of the Soviet republics to declare its independence but Moscow did not recognize this proclamation until September of 1991 (following the abortive coup in Moscow). The last Russian troops withdrew in 1993. Lithuania subsequently restructured its economy for integration into Western European institutions; it joined both NATO and the EU in the spring of 2004."},"id":"139","indexName":"country","timeStamp":20161019202028024,"modifyIndex":139,"highlights":[" and conquest Lithuania extended its territory to include <B>most</B> of present-day Belarus and Ukraine"," led the two <B>countries</B> into a union through the person of a common ruler. In 1569 Lithuania and Poland"],"score":0.20931896567344666},{"fields":{"background":"Although ultimately a victor in World Wars I and II France suffered extensive losses in its empire wealth manpower and rank as a dominant nation-state. Nevertheless France today is one of the most modern countries in the world and is a leader among European nations. Since 1958 it has constructed a hybrid presidential-parliamentary governing system resistant to the instabilities experienced in earlier more purely parliamentary administrations. In recent years its reconciliation and cooperation with Germany have proved central to the economic integration of Europe including the introduction of a common exchange currency the euro in January 1999. At present France is at the forefront of efforts to develop the EU's military capabilities to supplement progress toward an EU foreign policy."},"id":"84","indexName":"country","timeStamp":20161019202027856,"modifyIndex":84,"highlights":[" wealth manpower and rank as a dominant nation-state. Nevertheless France today is one of the <B>most</B>"," modern <B>countries</B> in the world and is a leader among European nations. Since 1958 it has constructed"],"score":0.20625202357769012},{"fields":{"background":"Close ties to France since independence in 1960 the development of cocoa production for export and foreign investment made Cote d'Ivoire one of the most prosperous of the West African states but did not protect it from political turmoil. In December 1999 a military coup - the first ever in Cote d'Ivoire's history - overthrew the government. Junta leader Robert GUEI blatantly rigged elections held in late 2000 and declared himself the winner. Popular protest forced him to step aside and brought Laurent GBAGBO into power. Ivorian dissidents and disaffected members of the military launched a failed coup attempt in September 2002. Rebel forces claimed the northern half of the country and in January 2003 were granted ministerial positions in a unity government under the auspices of the Linas-Marcoussis Peace Accord. President GBAGBO and rebel forces resumed implementation of the peace accord in December 2003 after a three-month stalemate but issues that sparked the civil war such as land reform and grounds for citizenship remained unresolved. In March 2007 President GBAGBO and former New Force rebel leader Guillaume SORO signed the Ouagadougou Political Agreement. As a result of the agreement SORO joined GBAGBO's government as Prime Minister and the two agreed to reunite the country by dismantling the zone of confidence separating North from South integrate rebel forces into the national armed forces and hold elections. Several thousand French and UN troops remain in Cote d'Ivoire to help the parties implement their commitments and to support the peace process."},"id":"61","indexName":"country","timeStamp":20161019202027800,"modifyIndex":62,"highlights":[" and foreign investment made Cote d'Ivoire one of the <B>most</B> <B>prosperous</B> of the West African states but did"],"score":0.18214824795722961},{"fields":{"background":"The French colonies of Senegal and the French Sudan were merged in 1959 and granted their independence as the Mali Federation in 1960. The union broke up after only a few months. Senegal joined with The Gambia to form the nominal confederation of Senegambia in 1982 but the envisaged integration of the two countries was never carried out and the union was dissolved in 1989. The Movement of Democratic Forces in the Casamance (MFDC) has led a low-level separatist insurgency in southern Senegal since the 1980s and several peace deals have failed to resolve the conflict. Nevertheless Senegal remains one of the most stable democracies in Africa. Senegal was ruled by a Socialist Party for 40 years until current President Abdoulaye WADE was elected in 2000. He was reelected in February 2007 but complaints of fraud led opposition parties to boycott June 2007 legislative polls. Senegal has a long history of participating in international peacekeeping."},"id":"206","indexName":"country","timeStamp":20161019202028156,"modifyIndex":206,"highlights":[" of the two <B>countries</B> was never carried out and the union was dissolved in 1989. The Movement"," remains one of the <B>most</B> stable democracies in Africa. Senegal was ruled by a Socialist Party for 40 years"],"score":0.17678746581077576},{"fields":{"background":"Venezuela was one of three countries that emerged from the collapse of Gran Colombia in 1830 (the others being Ecuador and New Granada which became Colombia). For most of the first half of the 20th century Venezuela was ruled by generally benevolent military strongmen who promoted the oil industry and allowed for some social reforms. Democratically elected governments have held sway since 1959. Hugo CHAVEZ president since 1999 seeks to implement his \"21st Century Socialism \" which purports to alleviate social ills while at the same time attacking globalization and undermining regional stability. Current concerns include: a weakening of democratic institutions political polarization a politicized military drug-related violence along the Colombian border increasing internal drug consumption overdependence on the petroleum industry with its price fluctuations and irresponsible mining operations that are endangering the rain forest and indigenous peoples."},"id":"251","indexName":"country","timeStamp":20161019202028256,"modifyIndex":251,"highlights":["Venezuela was one of three <B>countries</B> that emerged from the collapse of Gran Colombia in 1830"," (the others being Ecuador and New Granada which became Colombia). For <B>most</B> of the first half of the 20th"],"score":0.17678746581077576},{"fields":{"background":"As Europe's largest economy and second most populous nation (after Russia) Germany is a key member of the continent's economic political and defense organizations. European power struggles immersed Germany in two devastating World Wars in the first half of the 20th century and left the country occupied by the victorious Allied powers of the US UK France and the Soviet Union in 1945. With the advent of the Cold War two German states were formed in 1949: the western Federal Republic of Germany (FRG) and the eastern German Democratic Republic (GDR). The democratic FRG embedded itself in key Western economic and security organizations the EC which became the EU and NATO while the Communist GDR was on the front line of the Soviet-led Warsaw Pact. The decline of the USSR and the end of the Cold War allowed for German unification in 1990. Since then Germany has expended considerable funds to bring Eastern productivity and wages up to Western standards. In January 1999 Germany and 10 other EU countries introduced a common European exchange currency the euro."},"id":"91","indexName":"country","timeStamp":20161019202027868,"modifyIndex":91,"highlights":["As Europe's largest economy and second <B>most</B> populous nation (after Russia) Germany is a key member"," <B>countries</B> introduced a common European exchange currency the euro."],"score":0.147322878241539},{"fields":{"background":"Once the seat of Viking raiders and later a major north European power Denmark has evolved into a modern prosperous nation that is participating in the general political and economic integration of Europe. It joined NATO in 1949 and the EEC (now the EU) in 1973. However the country has opted out of certain elements of the European Union's Maastricht Treaty including the European Economic and Monetary Union (EMU) European defense cooperation and issues concerning certain justice and home affairs."},"id":"66","indexName":"country","timeStamp":20161019202027816,"modifyIndex":67,"highlights":[" into a modern <B>prosperous</B> nation that is participating in the general political and economic integration"],"score":0.13204053044319153}],"recordsReturned":10,"bestScore":0.7496965,"totalAvailable":73},"error":null}