Created
June 29, 2012 17:27
-
-
Save agilejon/3019414 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public PlayCard GetClosestMatch(PlayCard playCard, long teamId) | |
| { | |
| try | |
| { | |
| var solr = SolrProxy.GetConnection<IndexedPlayCard>(); | |
| var playCardDataQueries = IndexedPlayCard.GetPlayCardDataQueries(playCard.Data); | |
| if (!playCardDataQueries.Any()) return null; | |
| var results = solr.Query(new SolrMultipleCriteriaQuery(playCardDataQueries), new QueryOptions | |
| { | |
| Rows = 1, | |
| FilterQueries = GetFilterQueries(playCard), | |
| ExtraParams = new Dictionary<string, string> | |
| { | |
| {"qt", "playcard_match"}, | |
| //{"bq", GetOpponentBoostQuery(playCard)} | |
| } | |
| }); | |
| var playCardId = results.Select(i => i.PlayCardId).SingleOrDefault(); | |
| if (playCardId == null) return null; | |
| return ServiceManager.GetService<IPlayCardService>().GetPlayCardById(playCardId, teamId); | |
| } | |
| catch (SolrConnectionException ce) | |
| { | |
| Log.Error("Error connecting to Solr", ce); | |
| throw; | |
| } | |
| catch (Exception ex) | |
| { | |
| Log.Error(string.Format("Error querying {0} in Solr", GetType().FullName), ex); | |
| throw; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment